getting_started/first_3d_game/03.player_movement_code #78
Replies: 22 comments 51 replies
-
Shouldn't the CameraPivot be attached to the player somehow? |
Beta Was this translation helpful? Give feedback.
-
When I follow these instructions, I end up with the camera looking directly down, with no angle. How should I fix this? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Isn't this incorrect? My understanding is _physics_process() runs at a fixed rate independent of visual frame rate. Maybe explaining fixed rate updates and physics frames is out of the scope of this tutorial, but I think it can lead to confusion to those who are completely new to game dev. |
Beta Was this translation helpful? Give feedback.
-
# The downward acceleration when in the air, in meters per second squared.
@export var fall_acceleration = 75 75 is much greater than earth's gravity (~9.8m/s2). Is that so that the player falls faster? Or is there some mechanical reason for that? (or is the comment wrong?) |
Beta Was this translation helpful? Give feedback.
-
There's no instruction to raise the Y position of the camera. |
Beta Was this translation helpful? Give feedback.
-
if not is_on_floor(): # If in the air, fall towards the floor. Literally gravity
target_velocity.y = target_velocity.y - (fall_acceleration * delta) Why not just |
Beta Was this translation helpful? Give feedback.
-
My forward backword movement is inverted |
Beta Was this translation helpful? Give feedback.
-
My code doesn't do anything. I'm trying to code with C# using Visual Studio Code and the code seems to be connected to the project correctly as when I click the "script" icon on the Player scene it opens VS Code with the all the code in it. When I play the game however the code seems like it doesn't do anything. I've tried debugging it by printing lines in output when the buttons in the input are pressed but that also doesn't happen. I've also added the proper inputs in the editor. I've also tried just copying the entire code from this page into VS Code and that didn't work. At this point I'm assuming it's something with the editor, and I've even downloaded the Godot Engine .NET from their website, reloaded the project and it also didn't work. I don't know what's going on, can anybody give me a hand? |
Beta Was this translation helpful? Give feedback.
-
What counts as "floor" though? I think it would be useful to have a short explanation of that. As far as I can tell, the big rectangle we created doesn't have any special properties that would label it as "floor" (as opposed to "wall", "character" etc.). I presume that any collision shape is a floor as far as |
Beta Was this translation helpful? Give feedback.
-
I have this mostly working, the player is visible on the floor, stationery. When I click any of the movement keys the character moves in that direction, then falls through the floor. I thought it must be the When I launch the game I now see the player fall and stop at the floor. But when I press a key to move, the player still falls through the ground again. A number of times I went to run the game and I'd see a grey window, not my game .. took me a while to notice that it was when I was tinkering with the Player, because the 'main' scene tab isn't selected (player tab was), so the scene being 'run' was not the 'main' but the 'player' scene which has no camera🤦♂️ |
Beta Was this translation helpful? Give feedback.
-
The movement works just fine with GDScript, but it doesn't work with C#. I am using the exact code provided. |
Beta Was this translation helpful? Give feedback.
-
why use .ZERO instead of initialising the Vector3D like: "Vector3D(0.0, 0.0, 0.0)" is there a reason or is it just clarity and ease of use? |
Beta Was this translation helpful? Give feedback.
-
These are hilariously easy to follow; thanks, I love it! (I have a bouncy sprite moving across the screen in 2d thanks to bouncysprite.gdextension, & I tried to modify it to make a movecharacter.gdextension for 3d using vector3 & character_body3d, but i'm honestly lost) I am grateful for any and all assistance! Thanks |
Beta Was this translation helpful? Give feedback.
-
Im getting an error code |
Beta Was this translation helpful? Give feedback.
-
One comment, in the Previous lesson, I moved my Player's CollisionShape3D Position up too high, to y = 1m. It kept falling halfway through the floor. I changed it to 0.5m and it's fine now. |
Beta Was this translation helpful? Give feedback.
-
So the player didn't move for me at first. But then I noticed that in the Node tree view my player was not showing a script / document icon - and then I realised - I had added the player.glb model file instead of the scene file. I removed the node and added the child scene instance of scene.tscn and then it all worked great. I hope that helps other people. :-) |
Beta Was this translation helpful? Give feedback.
-
I could not found any CameraPivot node to add while using Godot Engine v4.4 I might be missing something, but I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Is there a particular reason or advantage to put Camera3D under a pivot node? Why don't we position and rotate camera directly? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi! I've been stuck at running the scene but only getting a grey background. Think it's about something regarding directional light or the player.glb file. Tried many configs in both but can't get it working properly, can anybody help? |
Beta Was this translation helpful? Give feedback.
-
Is there a reason to multiply fall acceleration by delta when using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
getting_started/first_3d_game/03.player_movement_code
It's time to code! We're going to use the input actions we created in the last part to move the character. Right-click the Player node and select Attach Script to add a new script to it. In the pop...
https://docs.godotengine.org/en/stable/getting_started/first_3d_game/03.player_movement_code.html
Beta Was this translation helpful? Give feedback.
All reactions