Skip to content

Commit 87875a3

Browse files
authored
[Reviewed] [3rd person camera] Allow to smooth the elevation angle (#1637)
1 parent 3c646fa commit 87875a3

1 file changed

Lines changed: 238 additions & 18 deletions

File tree

extensions/reviewed/ThirdPersonCamera.json

Lines changed: 238 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"author": "",
33
"category": "Camera",
44
"extensionNamespace": "",
5-
"gdevelopVersion": ">=5.5.222",
65
"fullName": "Third person camera",
6+
"gdevelopVersion": ">=5.5.222",
77
"helpPath": "",
88
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQo8L3N0eWxlPg0KPHBvbHlnb24gY2xhc3M9InN0MCIgcG9pbnRzPSI3LDEwIDEsMTMgNywxNiAxMywxMyAiLz4NCjxwb2x5bGluZSBjbGFzcz0ic3QwIiBwb2ludHM9IjEsMTMgMSwyMCA3LDIzIDEzLDIwIDEzLDEzICIvPg0KPGxpbmUgY2xhc3M9InN0MCIgeDE9IjciIHkxPSIxNiIgeDI9IjciIHkyPSIyMyIvPg0KPGxpbmUgY2xhc3M9InN0MCIgeDE9IjMxIiB5MT0iMTYiIHgyPSIyMSIgeTI9IjgiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyMSIgeTE9IjI0IiB4Mj0iMzEiIHkyPSIxNiIvPg0KPHBhdGggY2xhc3M9InN0MCIgZD0iTTIyLjcsMjIuNkMyMCwyMS43LDE4LDE5LjEsMTgsMTZjMC0zLjEsMi01LjcsNC43LTYuNiIvPg0KPHBhdGggY2xhc3M9InN0MCIgZD0iTTE5LjgsMTEuM2MxLjQsMS4xLDIuMiwyLjgsMi4yLDQuN2MwLDEuOS0wLjksMy42LTIuMiw0LjciLz4NCjwvc3ZnPg0K",
99
"name": "ThirdPersonCamera",
1010
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/Virtual Reality/94e95d2c318e1f3dc7151a351024e13c574e1e44669c6696aa107d60230073f6_Virtual Reality_3d_vision_eye_vr.svg",
1111
"shortDescription": "Move the camera to look at an object from a given distance.",
12-
"version": "1.6.1",
12+
"version": "1.7.0",
1313
"description": [
1414
"Move the camera to look at an object from a given distance with a rotation and an elevation angles.",
1515
"",
@@ -583,6 +583,18 @@
583583
""
584584
]
585585
},
586+
{
587+
"type": {
588+
"value": "ThirdPersonCamera::ThirdPersonCamera::SetElevationHalfwayDuration"
589+
},
590+
"parameters": [
591+
"Object",
592+
"Behavior",
593+
"=",
594+
"ElevationHalfwayDuration",
595+
""
596+
]
597+
},
586598
{
587599
"type": {
588600
"value": "ThirdPersonCamera::ThirdPersonCamera::SetTranslationZHalfwayDuration"
@@ -646,24 +658,22 @@
646658
},
647659
{
648660
"type": {
649-
"value": "SetCameraAngle"
661+
"value": "SetNumberVariable"
650662
},
651663
"parameters": [
652-
"",
664+
"CameraZ",
653665
"=",
654-
"Object.Angle() + 90",
655-
"Object.Layer()",
656-
"0"
666+
"Object.Object3D::CenterZ()"
657667
]
658668
},
659669
{
660670
"type": {
661-
"value": "SetNumberVariable"
671+
"value": "ThirdPersonCamera::ThirdPersonCamera::JumpToTargetedRotation"
662672
},
663673
"parameters": [
664-
"CameraZ",
665-
"=",
666-
"Object.Object3D::CenterZ()"
674+
"Object",
675+
"Behavior",
676+
""
667677
]
668678
}
669679
]
@@ -912,6 +922,33 @@
912922
}
913923
]
914924
},
925+
{
926+
"type": "BuiltinCommonInstructions::Standard",
927+
"conditions": [
928+
{
929+
"type": {
930+
"value": "BooleanVariable"
931+
},
932+
"parameters": [
933+
"IsElevatingWithObject",
934+
"True",
935+
""
936+
]
937+
}
938+
],
939+
"actions": [
940+
{
941+
"type": {
942+
"value": "SetNumberVariable"
943+
},
944+
"parameters": [
945+
"TargetedElevationAngle",
946+
"=",
947+
"Object.Object3D::RotationY()"
948+
]
949+
}
950+
]
951+
},
915952
{
916953
"type": "BuiltinCommonInstructions::Standard",
917954
"conditions": [],
@@ -921,23 +958,33 @@
921958
"value": "SetNumberVariable"
922959
},
923960
"parameters": [
924-
"CameraAngle",
961+
"CameraRotationAngle",
925962
"=",
926963
"TargetedRotationAngle + 90 + RotationAngleOffset + AngleDifference(CameraAngle(Object.Layer()), TargetedRotationAngle + 90 + RotationAngleOffset) * exp(TimeDelta() * RotationLogSpeed)"
927964
]
928965
},
966+
{
967+
"type": {
968+
"value": "SetNumberVariable"
969+
},
970+
"parameters": [
971+
"CameraElevationAngle",
972+
"=",
973+
"TargetedElevationAngle + ElevationAngleOffset + AngleDifference(90 - Scene3D::CameraRotationX(Object.Layer()), TargetedElevationAngle + ElevationAngleOffset) * exp(TimeDelta() * ElevationLogSpeed)"
974+
]
975+
},
929976
{
930977
"type": {
931978
"value": "ThirdPersonCamera::LookFromDistanceAtPosition3D"
932979
},
933980
"parameters": [
934981
"",
935-
"Object.CenterX() + ThirdPersonCamera::RotatedX(CameraAngle, OffsetX, -OffsetY)",
936-
"Object.CenterY() + ThirdPersonCamera::RotatedY(CameraAngle, OffsetX, -OffsetY)",
982+
"Object.CenterX() + ThirdPersonCamera::RotatedX(CameraRotationAngle, OffsetX, -OffsetY)",
983+
"Object.CenterY() + ThirdPersonCamera::RotatedY(CameraRotationAngle, OffsetX, -OffsetY)",
937984
"CameraZ + OffsetZ",
938985
"Distance",
939-
"CameraAngle",
940-
"Object.Object3D::RotationY() + ElevationAngleOffset",
986+
"CameraRotationAngle",
987+
"CameraElevationAngle",
941988
"",
942989
""
943990
]
@@ -946,7 +993,12 @@
946993
"variables": [
947994
{
948995
"folded": true,
949-
"name": "CameraAngle",
996+
"name": "CameraRotationAngle",
997+
"type": "number",
998+
"value": 0
999+
},
1000+
{
1001+
"name": "CameraElevationAngle",
9501002
"type": "number",
9511003
"value": 0
9521004
}
@@ -976,7 +1028,6 @@
9761028
"fullName": "Rotate the camera all the way",
9771029
"functionType": "Action",
9781030
"name": "JumpToTargetedRotation",
979-
"private": true,
9801031
"sentence": "Rotate the camera all the way to the targeted angle of _PARAM0_",
9811032
"events": [
9821033
{
@@ -1006,6 +1057,33 @@
10061057
}
10071058
]
10081059
},
1060+
{
1061+
"type": "BuiltinCommonInstructions::Standard",
1062+
"conditions": [
1063+
{
1064+
"type": {
1065+
"value": "BooleanVariable"
1066+
},
1067+
"parameters": [
1068+
"IsElevatingWithObject",
1069+
"True",
1070+
""
1071+
]
1072+
}
1073+
],
1074+
"actions": [
1075+
{
1076+
"type": {
1077+
"value": "SetNumberVariable"
1078+
},
1079+
"parameters": [
1080+
"TargetedElevationAngle",
1081+
"=",
1082+
"Object.Object3D::RotationY()"
1083+
]
1084+
}
1085+
]
1086+
},
10091087
{
10101088
"type": "BuiltinCommonInstructions::Standard",
10111089
"conditions": [],
@@ -1251,6 +1329,108 @@
12511329
],
12521330
"objectGroups": []
12531331
},
1332+
{
1333+
"description": "the halfway time for elevation rotation of the object.",
1334+
"fullName": "Halfway time for elevation rotation",
1335+
"functionType": "ExpressionAndCondition",
1336+
"group": "Third person camera configuration",
1337+
"name": "ElevationHalfwayDuration",
1338+
"sentence": "the halfway time for elevation rotation",
1339+
"events": [
1340+
{
1341+
"type": "BuiltinCommonInstructions::Standard",
1342+
"conditions": [],
1343+
"actions": [
1344+
{
1345+
"type": {
1346+
"value": "SetReturnNumber"
1347+
},
1348+
"parameters": [
1349+
"ElevationHalfwayDuration"
1350+
]
1351+
}
1352+
]
1353+
}
1354+
],
1355+
"expressionType": {
1356+
"type": "expression"
1357+
},
1358+
"parameters": [
1359+
{
1360+
"description": "Object",
1361+
"name": "Object",
1362+
"type": "object"
1363+
},
1364+
{
1365+
"description": "Behavior",
1366+
"name": "Behavior",
1367+
"supplementaryInformation": "ThirdPersonCamera::ThirdPersonCamera",
1368+
"type": "behavior"
1369+
}
1370+
],
1371+
"objectGroups": []
1372+
},
1373+
{
1374+
"fullName": "",
1375+
"functionType": "ActionWithOperator",
1376+
"getterName": "ElevationHalfwayDuration",
1377+
"name": "SetElevationHalfwayDuration",
1378+
"sentence": "",
1379+
"events": [
1380+
{
1381+
"type": "BuiltinCommonInstructions::Comment",
1382+
"color": {
1383+
"b": 109,
1384+
"g": 230,
1385+
"r": 255,
1386+
"textB": 0,
1387+
"textG": 0,
1388+
"textR": 0
1389+
},
1390+
"comment": "ln((1 - speed)) = ln(1 / 2) / halfwatTime"
1391+
},
1392+
{
1393+
"type": "BuiltinCommonInstructions::Standard",
1394+
"conditions": [],
1395+
"actions": [
1396+
{
1397+
"type": {
1398+
"value": "SetNumberVariable"
1399+
},
1400+
"parameters": [
1401+
"ElevationHalfwayDuration",
1402+
"=",
1403+
"Value"
1404+
]
1405+
},
1406+
{
1407+
"type": {
1408+
"value": "SetNumberVariable"
1409+
},
1410+
"parameters": [
1411+
"ElevationLogSpeed",
1412+
"=",
1413+
"log(0.5) / Value"
1414+
]
1415+
}
1416+
]
1417+
}
1418+
],
1419+
"parameters": [
1420+
{
1421+
"description": "Object",
1422+
"name": "Object",
1423+
"type": "object"
1424+
},
1425+
{
1426+
"description": "Behavior",
1427+
"name": "Behavior",
1428+
"supplementaryInformation": "ThirdPersonCamera::ThirdPersonCamera",
1429+
"type": "behavior"
1430+
}
1431+
],
1432+
"objectGroups": []
1433+
},
12541434
{
12551435
"description": "the halfway time on Z axis of the object.",
12561436
"fullName": "Halfway time on Z axis",
@@ -2190,6 +2370,16 @@
21902370
"extraInformation": [],
21912371
"name": "RotationHalfwayDuration"
21922372
},
2373+
{
2374+
"value": "0",
2375+
"type": "Number",
2376+
"unit": "Second",
2377+
"label": "Halfway time for elevation rotation",
2378+
"description": "",
2379+
"group": "Catch-up speed",
2380+
"extraInformation": [],
2381+
"name": "ElevationHalfwayDuration"
2382+
},
21932383
{
21942384
"value": "0.125",
21952385
"type": "Number",
@@ -2292,6 +2482,16 @@
22922482
"hidden": true,
22932483
"name": "RotationLogSpeed"
22942484
},
2485+
{
2486+
"value": "",
2487+
"type": "Number",
2488+
"label": "",
2489+
"description": "",
2490+
"group": "",
2491+
"extraInformation": [],
2492+
"hidden": true,
2493+
"name": "ElevationLogSpeed"
2494+
},
22952495
{
22962496
"value": "",
22972497
"type": "Number",
@@ -2342,6 +2542,15 @@
23422542
"extraInformation": [],
23432543
"name": "IsRotatingWithObject"
23442544
},
2545+
{
2546+
"value": "false",
2547+
"type": "Boolean",
2548+
"label": "Automatically rotate the camera with the object (elevation)",
2549+
"description": "",
2550+
"group": "",
2551+
"extraInformation": [],
2552+
"name": "IsElevatingWithObject"
2553+
},
23452554
{
23462555
"value": "0",
23472556
"type": "Number",
@@ -2352,6 +2561,17 @@
23522561
"extraInformation": [],
23532562
"hidden": true,
23542563
"name": "TargetedRotationAngle"
2564+
},
2565+
{
2566+
"value": "0",
2567+
"type": "Number",
2568+
"unit": "DegreeAngle",
2569+
"label": "Targeted camera rotation angle",
2570+
"description": "When this angle is set, the camera follow this value instead of the object angle.",
2571+
"group": "",
2572+
"extraInformation": [],
2573+
"hidden": true,
2574+
"name": "TargetedElevationAngle"
23552575
}
23562576
],
23572577
"sharedPropertyDescriptors": []

0 commit comments

Comments
 (0)