Hello everyone,
I am trying to do a rotation like this video
the problem is I have camera attached to my player so when I tried using his rotation, the whole
screen rotations around the camera.
I tried changing the line to
fire_point.eulerAngles=new Vector3(0, 0, angle);
but the object just spins in place. It doesn’t rotate around the player with some distance away.
I have made my fire_point a child of the player and pulled it some distance out.
EDIT: to clarify, the object is always some distance under the player. I want it to rotate around the player, following the mouse with a distance.
1 Answer
1
It is very simple if you think carefully. My approach is not best but it is very simple.
If camera is following your player, then you can do following steps.
- Create an empty Game Object which will follow the player (don’t make it child of player game object). Use script to handle follow behaviour. Let’s call this game object playerFollowObject.
- Make your fire point game object child of this playerFollowObject object created.
- Now, you can use camera methods to convert mouse position to world position (which you might have already done).
- Get the direction between playerFollowObject and mouse position (In world position) and rotate your playerFollowObject.
- This will automatically rotate your fire point game object where mouse is pointing.
I have attached a screenshot to help you understand how you playerFollowObject and fire point should be.

thank you. I just arrived at something similar, but I think yours is better. thanks again!
– partimelheroYou're most welcome. If it is helped you please mark it as answer.
– swappy123