Question by
rivecal21 · Feb 24, 2018 at 11:06 AM ·
c#mousepositionorbit
Position an object at a specific point in an orbit
So I'm trying to make a small sphere(we'll call it bullet for simplicity) around the player sphere, that hovers about 0.75 units off of the player, towards the mouse. Basically, the camera is on the side of the level, the player is on 0.0f on their Z axis, and I want the ball to always be pointing to the camera at an offset of 0.75 units from the center of the ball.
Vector3 v3 = Input.mousePosition; // This line, and the next two are designed to fetch the mouse position.
v3.z = 0.0f;
v3 = Camera.main.ScreenToWorldPoint(v3);
Vector3 Dir = transform.position - v3; // This creates a direction between the mouse and the character
Dir.Normalize(); // Normalization for good measure
/*
* This moves the bullet ball around the player sphere to point to the mouse- I don't get why this isn't working.
*/
Bullet.transform.position = transform.position + Dir * 0.75f;
Comment
Your answer
Follow this Question
Related Questions
Orbit position controlled by mouse 2D (C#) 0 Answers
Shoot towards mouse except mouse y 1 Answer
Can't get raycast to mousePosition 0 Answers
Intercepting planet in orbit on a straight path? 0 Answers
How is this done with UNİTY ? 1 Answer