I Am Trying To Figure Out How To Get A Object/item To Follow A Camera So It Faces The Same Direction As The Player, Can Anyone Help?
Check out this post:
What i know of the project i think you mean a object that is always in front of the camera. (Like the weapon of the player visible in front of the camera). Maybe @Leonidas know how to do that.
The easiest way is to add the camera as a child to the object that you are moving. Then the camera will move and rotate together with the object.
But a more proper solution usually requires additional code to setup, you can take a look at the post I’ve attached above.
is there any way to do this without legacy scripts?
You don’t need legacy scripts, just need to code this solution in your project.
If you aren’t able or proficient to do this, then try the simplest of the solutions:
- Add your camera in the editor as child to the entity you need to follow/look at.
Is this working if you use a Third Person Camara script? Because then I experience that if you set a entity as a child of the camera it does not rotate with the camera. It only moves with the camera.
Without coding a solution there aren’t many things you can do.
What I said will work only if your character controller rotates the player and you set the camera as a direct child. Then yes, it will rotate as well.
Otherwise, as you say, you need to code a solution (e.g. using lookAt).
Ah i’m sorry, I don’t read it well i think.
If I understand correctly this should work?
Player (with script) > Item (that moves with camera) > camera
Yes, you can easily test it yourself in an empty project:
- Add the camera as child to an entity.
- Rotate that entity in editor and see the camera rotate as well.
That is how the First Player Movement example works, the camera moves with the Playcanvas controller. In that example it rotates with the camera movement: