Skip navigation
Been playing a bit with Node2D, Polygon and UI with Godot, there's no native function to make a…
0:00 / 0:22

Been playing a bit with Node2D, Polygon and UI with Godot, there's no native function to make a…

Alex

@mustache_dev5.8K followers

Visit on X
768 likesDownloadOriginal post

37,752 views #indiedev #gamedev

Been playing a bit with Node2D, Polygon and UI with Godot, there's no native function to make a circle i can't believe that, anyway i wrote a shader based animated crossshair. Anyway, you want to learn how to make a smooth spaceship - controller ? 🧵 #indiedev #gamedev

43 Comments

Comments from the original post on X (Twitter)

  • Alex's profile picture

    @mustache_dev

    let's talk about the scene graph. Weither you play with Godot, Three.js, or basically anything, the logic is the same. The logic is on the character body 3D, physics or not. (for three.js, think of Node3D as there's you, your physical character

    36 likes

  • Alex's profile picture

    @mustache_dev

    And inside, there are 3 nodes you will need. The camera target, which is where your camera should be, the model node and your rigid body. The logic applies on the Rigid Body. The Camera node should NOT be in your player controller.

    13 likes

  • Alex's profile picture

    @mustache_dev

    One funny thing i saw on my first steps on Godot is how devs uses Vector3 for their inputs, it's a really smart idea. Godot uses XYZ same as Three (so you really are at home) And for your player the user will have a Vector3 input (Yaxis, X axis, Z axis).

    12 likes

  • Alex's profile picture

    @mustache_dev

    Aside the practical way this offer, this is done to use the Vector3().normalize function because with Joystick you can push your inputs out of your normal with the diagonals. Never saw that before with my years of three.js, but will not turn back.

    10 likes

  • Alex's profile picture

    @mustache_dev

    Anyway, let's split things up : First I will talk briefly about the camera, then for the player movement, I split it in 3 distinct functions : Yaw (left, right) Pitch(up, down) and roll(roll over the Z axis)

    10 likes

  • Alex's profile picture

    @mustache_dev

    First the camera, the camera target node should be set behind, slightly above the player, this is the place your camera should follow, instead of straigth up moving your camera at that place, you will lerp your camera and slerp the quaternion to get a more natural motion

    16 likes

  • Alex's profile picture

    @mustache_dev

    With this, instead of arbitrarily moving and playing with the camera, you get a totally natural camera movement, add some FOV animation with the speed, or focusing, and you will get a good feeling already

    11 likes

  • Alex's profile picture

    @mustache_dev

    Now that the good camera is setup, let's move the ship, starting with the yaw. The idea with pitch, roll, and yaw is to rotate infinitely the ship based on the inputs, but as You work in 3D Space, let's say your Y rotation is = PI Then your X axis is reversed

    12 likes

  • Alex's profile picture

    @mustache_dev

    This is why we need to always work with the player's current rotation, and the logic will be applied for pitch yaw and roll. Sorry for the arbitrary 0.02, it's the rotation speed. A smoother way would be to lerp the rotation speed when you start turning instead of direct value

    12 likes

  • Alex's profile picture

    @mustache_dev

    But to add, some more living animation, you need to animate the model, the model shouldn't be tied to physical constraints since you're playing an arcade game and not a sim So you can add a damping function on the y position when pitching up and down, with the camera lerp

    9 likes

  • Alex's profile picture

    @mustache_dev

    it feels natural, there's no issues. But playing and looking at battlefront 2 Gameplay This wasn't enough, I noticed something, will you ?

    13 likes

  • Alex's profile picture

    @mustache_dev

    The model always slightly overshoot the turn, weither with rolling, pitching, or yawing. But how to define an overturn ? what could be the logic behind it, cuz you can't apply it everytime. It took me a while, but I understood it

    10 likes

  • Alex's profile picture

    @mustache_dev

    So you can get an overshoot, overdoes the roll, and apply it to your damping animations, lots of arbitrary values, but those are just iteration, i need to define proper variable.

    12 likes

  • Alex's profile picture

    @mustache_dev

    The overshoot logic is based on how fast the player moves the inputs, how fast it goes from 0 to 1 or -1 the difference between the 2, when playing with joystick or mouse applies a very natural overshoot feeling.

    11 likes

  • Alex's profile picture

    @mustache_dev

    By getting your 'input speed' however you call it, you can add so much natural motion that will react to the player's real life movement, it adds life to your movements.

    15 likes

  • Alex's profile picture

    @mustache_dev

    That's about it for the tutorial, with this logic you can do it ! Open source code here :

    36 likes

  • Martin Ziel's profile picture

    @zilluss

    There are native functions, either in the draw_circle draw call of a node or Line2D

    5 likes

  • Alex's profile picture

    @mustache_dev

    I saw the draw but not the draw circle 😅

    3 likes

  • JyveTech's profile picture

    @JyveTech

    @zilluss Can make a gradient texture, set it to be 2d, and add 3 points, black transparent, white opaque, black transparent. Then control the scale to zoom in/pulse/change the colour of the ring. Anti aliases well. Would this work for what you're trying to do?

    5 likes

  • Alex's profile picture

    @mustache_dev

    @zilluss Well in the end I made a shader from which I can control the ring size everything, control the angle start/angle end, and I can control all the values to animate the laser overheat effect

    4 likes