Camera and Keyboard Controls with C# & Godot [Andromedoom Dev Log 2]
Polysthetic
๐พWelcome to the Andromedoom dev logs! In episode 2, I'm setting up the keyboard controls for moving the player pad and camera using a pair of gimbals. In the dev log, I will be presenting the Bathymetroids, the oceanic themed aliens invading the Asia-Pacific region. I hope you enjoy this video series and stick around for the game's development! ๐
โฑ๏ธ Timestamps: 0:00 Intro 1:05 Intro - Scene structure 1:49 Input mapping in Godot 2:52 Scripting - Receiving keyboard inputs 5:25 Setting up camera movement with nested spatial nodes 7:45 Scripting - Camera movement 15:43 Understanding basis vectors and transform matrices 18:10 Scripting - Player rotation 26:55 Dev log - Aliens! Bathymetroids!
๐ป Addenda:
- Be careful with the "as" keyword. If the cast is invalid, it will silently null that reference. Using generics will throw an exception, so they are a more defensive way of casting.
- When rotating objects, it's a good idea to orthonormalise their basis by using Transform.Basis.Orthnormalize(). This will correct for any floating point errors that would otherwise accumulate over time, and result in offsets in scaling and rotation.
- You can use Transform.Basis.Xform(movementVector) to simply multiply the vector by the basis. This is equivalent to Transform.basis.x * movement.x + Transform.basis.y + Transform.basis.z.
- To move forward or to the right, you only need to use Basis.x or Basis.z, instead of multiplying by the relative vector. However, if you're moving in a composite direction (like from a joystick), then you need to multiply by the basis matrix.
- To normalise the movement input, I should have just normalised the output from the keyboard, instead of taking the magnitude and multiplying again. ๐ Recording off the cuff is hard!
- I read the documentation for Godot, and it appears that throwing triangles at a mobile GPU isn't as demanding as alpha/transparent textures, so my mileage may vary. Regardless, the models are so simple, I doubt it will matter.
๐ถ Music tracks from:
- Dillan Witherow - Before Sunrise
- Provided by Lofi Girl
- Watch: https://www.youtube.com/watch?v=sDC_ssw-eWI
You can also visit me at: WEBSITE ๐ https://polysthetic.com THREADLESS ๐ถ๏ธ https://polysthetic.threadless.com DRIBBBLE ๐ https://dribbble.com/polysthetic YOUTUBE ๐ฅ https://youtube.com/c/polysthetic AUDIOMACK ๐ผ https://audiomack.com/polysthetic ... https://www.youtube.com/watch?v=zflfXwy5Wk8
162845164 Bytes