Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Dahaarl | |
Old Version | Published before Godot 3 was released. |
Hey ! I’m trying to make 3rd person movements like Psychonauts or Ratchet & Clank and my problem is that the rotation of the camera is use to lead the character and I don’t understand how I could do that (even in terms of “logic”).
My basics movements are based on linear velocity on a RigidBody and support 8 directions movements in the 3D space.
func move_player(speed_x,speed_z, acc, delta):
current_speed.x = lerp(current_speed.x, speed_x, acc * delta)
current_speed.z = lerp(current_speed.z, speed_z, acc * delta)
set_linear_velocity(Vector3(current_speed.x,get_linear_velocity().y, current_speed.z))
func _fixed_process(delta):
if btn_up:
move_player(0,-speed, acceleration, delta)
if btn_down:
move_player(0,speed, acceleration, delta)
## etc...
I think that I should use the forward vector of the camera (var forward = -camera.get_transform().basis.z
) but I don’t know what to do with it…
you can take the camera’s forward vector and multiply it to get a forward - backwards movement, and by using the normal vector or the vector’s orientation and some trigonometry you can find the vector for horizontal movement. i dont remember the equations too much but you can look up google or try and develop them yourself if you are educated in those subjects
rustyStriker | 2017-11-04 12:32