Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Really awesome!! I was trying to add some basic movement to the project but not sure how to determine what's forward since your project rotates the camera only and wouldn't rotate the root player node. Any solution?

(+1)

figured it out! replaced camera_rotation = look_rotation + recoil

with these three lines

var final_rotation = look_rotation + recoil

camera_rotation.rotation.x = final_rotation.x

player.rotation.y = final_rotation.y

(+1)

glad you got it working!

(+1)

also, the code you refered to "camera_rotation = look_rotation + recoil" is not the real code.

the actual code can be found here:

https://github.com/atornity/godot_recoil_system/blob/master/scripts/camera.gd#L7...

just in case you didn't know :3

(2 edits) (+1)

glad you liked it! I see you figured it out already witch is great. The way I would do it is a bit different.

for move left/right I would use "camera.basis.x" as the move direction. for forward/backward I would use "player.basis.y.cross(camera.basis.x)".

which might look something like:


var input: Vector2 = Input.get_vector(...) # replace '...' with move input mappings

var forward_axis: Vector3 = player.basis.y.cross(camera.basis.x)

var right_axis: Vector3 = camera.basis.x

var move_vector = input.x * forward_axis + input.y * right_axis

player.move(move_vector * speed)


I personally prefer to keep the camera rotation completely separate from the player rotation but that's completely up to you of course :3

(1 edit) (+1)

I see that's very interesting. are there any benefits to keeping the rotation of the player and the camera separate?

(1 edit)

1. it allows your camera script to exist without having a reference to a player. Which might be useful sometimes.

2. camera node does not have to be a child of the player node (although it can still be if you want)

3. for first person games, it allows you to attach a legs/feet mesh to your player without it being dependent on the rotation of the camera.

4. for third person games, it allows for more smooth camera movement where the camera isn't actually attached to the player (2). It also allows the player to have a different rotation from the camera which is very common for third person games.

5. it allows you to use the same camera script for first person games and third person games. (and other types of games probably)

It's all kind of small benefits that can be easily worked around. In the end it comes down to personal preference more than anything :3