Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhantomCamera3D.set_third_person_rotation() rotates the camera around its own #399

Open
marinho opened this issue Oct 9, 2024 · 4 comments

Comments

@marinho
Copy link

marinho commented Oct 9, 2024

Issue description

For a PCam with follow_mode as ThirdPerson, I wrote this code expecting the camera to rotate around the target (which is the character object), but instead, this method is actually rotating the camera around its own Y.

const SPEED = 5

func _input(event):
	if event is InputEventMouseMotion:
		var x = event.relative.x * 0.001 * SPEED
		var old_rotation = %PCamThirdPerson.get_third_person_rotation()
		var new_rotation = Vector3(
			old_rotation.x,
			old_rotation.y + x,
			old_rotation.z
		)
		%PCamThirdPerson.set_third_person_rotation(new_rotation)

Steps to reproduce

  1. Add a CharacterBody3D, Camera3D, PCamHost and PCam to the scene, plus some ground with respective collisions
  2. Set PCam with:
    a. Priority = 0
    b. Follow Mode = Third Person
    c. Follow Target = CharacterBody3D
    d. Follow Offset = (0, 10, 10)
    e. Spring Length = 10
    f. Create a script and add the code I wrote above
    g. Run

(Optional) Minimal reproduction project

Additionally, if I set Look at Mode to Siple and Look at Target to CharacterBody3D (in face any other object), the camera will as well point to bottom with no clear reason.

Thanks!

@asvetin
Copy link

asvetin commented Jan 14, 2025

@marinho A bit late, but if you don't set the follow offset the rotation will work ( rotate around the point ).
That was my solution/fix

@ramokz
Copy link
Owner

ramokz commented Jan 14, 2025

Sorry, missed the initial post for this.

Yes, the offset effectively sets the position of the spring arm.
So if you change that, then you also change the point that it will orbit around.

@marinho
Copy link
Author

marinho commented Jan 15, 2025

thank you folks. I haven't worked on this project for a while, so, I must look back into it to recall if I made it to get it fixed anyhow. thank you again!

@ramokz
Copy link
Owner

ramokz commented Jan 16, 2025

I think this does raise the question of whether if there would be value in having the option to both offset the spring arm's point position and the camera itself relative to the spring arm's spring_length point. As opposed to just the former, like how it is currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants