-1
\$\begingroup\$

I have a 3D game looking from top to bottom where I move the mouse to aim at targets.

I have a simple box (the player) with a sphere on its middle-front (that is the pistol) and a cylinder on its right (that is the machine gun).

When I use the pistol I can make the player look at the target in a way it can send the bullets in the correct direction and it will hit the target position... that's okay.

The problem is when I send the bullets from the cylinder. It will not hit the target because it is attached to the right side of the cube. The bullets will come out of the cylinder straight forward and will pass near the target position. How can I rotate the player in a way that the cylinder will be pointing exactly to the target?

\$\endgroup\$
3
  • \$\begingroup\$ What are you using to do this? Unity, Unreal, your own engine? \$\endgroup\$ Commented Jul 30, 2015 at 20:58
  • \$\begingroup\$ Im using Unity C#. \$\endgroup\$ Commented Jul 31, 2015 at 12:43
  • \$\begingroup\$ Are you using raycast? \$\endgroup\$ Commented Aug 1, 2015 at 5:43

1 Answer 1

0
\$\begingroup\$

You could create an empty game object and make it a child of the cylinder, attach the your shooting script, then change the position of the empty game object to what ever suits you this will solve the rotation problem and will probably not be very noticeable.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.