@Dschoonmaker Okay, i thought the difference between the two cameras was minimal. I have replaced the camera and I still see the issue, I thought that moving around the camera offset value would fix it also. I put the project on github, all the files should be in the rar. The scene in question is the spatial tscn one I think. https://github.com/emptygrimoire/camera_and_movement_godot/blob/master/copy_project_movement_camera/project_try/assets/project_try.rar

I changed the lines

	cameraAngle.x += event.relative.x
	cameraAngle.y += event.relative.y

to

	cameraAngle.x += event.relative.x*mouse_sensitivity*get_physics_process_delta_time()
	cameraAngle.y += event.relative.y*mouse_sensitivity*get_physics_process_delta_time()

the camera movement was way too fast, and mouse_sensitivity wasn't doing anything, so I multiplied it by mouse_sensitivity. It also wasn't being multiplied by delta, so I added that as well.

Also, after the camera movement, I added

$Camera.look_at(global_transform.origin+cameraOffset,Vector3.UP)

to rotate the camera in the right direction. There were some other problems in the code(one that caused the player to move far out of the map), but these changes should make the camera & moving relative to the camera work.

@Dschoonmaker yes, it is nice to a see a functional camera now. the amount of work and advice i needed to get this far makes me think I'm not suited for 3D right now. too ambitious. Appreciate the help

eh, just a matter of time investment. There is a lot of minutiae to know.

You have a lot to learn, but everyone does at some point. It took a lot of time and effort to get that third person camera code working. If you persist, you can learn 3D gamedev in a matter of time.

That's not to say making simpler 2D games first isn't also helpful, but if you've already done some game development, you can probably move on to 3D. You've got to start somewhere, and in my experience, the people on godotforums are always happy to help.

16 days later

Hi I'm new here. I was following along on this and I was wondering where would you add animation the correct way? I was able to animate a run and Idle animation but when I turn the camera in a different direction, the animation does not follow correctly in that animation. Does this make sense?

Here are some changes I made to the code:

var something = false

I added this in the "func handle_movement(delta):"

if something == true:
	moveDir = moveDir.linear_interpolate(moveDir * speed, accel * delta)
else:
	moveDir = Vector3.ZERO

if is_on_floor():
	if Input.is_action_pressed("ui_up"):
		something = true
	if Input.is_action_pressed("ui_down"):
		something = true
	if Input.is_action_pressed("ui_left"):
		something = true
	if Input.is_action_pressed("ui_right"):
		something = true

	if !Input.is_action_pressed("ui_up") and !Input.is_action_pressed("ui_down") and !Input.is_action_pressed("ui_left") and !Input.is_action_pressed("ui_right"):
		something = false
		anim.play("Idle")
	else:
		anim.play("RunForward")
		something = true

I added in the "something" variable because when I ran the original code I slid without pressing a button. I am still new to coding so sorry if this code is weird lol.

What's your problem? Some kind of animation problem?

I think so. The animation works correct when I run forward, but once I move the camera lets say to the right side and press the forward button again, the animation looks like it's running sideways. Does this make sense?

@Dschoonmaker said: What's your problem? Some kind of animation problem?

Could it be solved using some type of rotation of the animation? Or like set position of animation to camera position?

So it's always rotated to face forward, and doesn't rotate when you rotate the camera?

@Dschoonmaker said: So it's always rotated to face forward, and doesn't rotate when you rotate the camera?

Yes. This is correct. Actually, the animation never rotated to begin with.

I rotate my player with look_at(moveDir), moveDir being the direction the player is moving in(not necessarily velocity, but the direction of input). I also set the Y value of that look_at vector to 0, to make sure the player faces horizontally. I also combine that with a special angle lerp function I have, so that the player doesn't turn instantly, but look_at() is the main part of my rotation code.

I think, I found out where the mistake was. I don't use the onready var camera_pivot anywhere in the code. This is what I have for it.

onready var camera_pivot = get_node("/root/Playertest") onready var camera = $Camera

I was reading through the comments and couldn't find how they used camera_pivot. They used it in the func _input(event), but it doesn't seem to work right so I commented it out (It makes the player rotate up and down). This is what I have for that.

What is camera_pivot? It doesn't look like you have that node anywhere in your scene.

Its the player node. I was reading through the previous comments and they seem to change it every time and I couldn't figure out what they left it as.

onready var camera_pivot = get_node("/root/Playertest")

Here is the whole code I have for it at the moment, A lot of stuff is commented out. I was also looking back at it and found out that a function called rotateAround is not being used. I was trying to figure out how to put it in the code so that it can run the function, but no luck.

extends KinematicBody

5 days later

Thanks for the help. I found a tutorial online that helped me out with my problem. This is the link:

2 years later