playMaker

Author Topic: Storing player position issues [SOLVED]  (Read 1635 times)

Sam0Saurus

  • Playmaker Newbie
  • *
  • Posts: 2
Storing player position issues [SOLVED]
« on: July 14, 2013, 12:53:09 AM »
I'm making a top down shooter with 2d sprites for characters in a 3d environment and I'm having trouble making my enemies shoot at my player character.

My bullets are prefabs and all the solutions I can think of involve pointing the bullets towards a scene object. This is impossible in unity though :(. I've tried storing my players x and z coordinates in a vector 3, and then rotating the bullets towards those coordinates + applying force, but it doesn't work.

Can anyone suggest a way to get my enemies to shoot at my non prefab character controller?
« Last Edit: July 14, 2013, 01:41:25 AM by Sam0Saurus »

Sam0Saurus

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Storing player position issues [SOLVED]
« Reply #1 on: July 14, 2013, 01:44:54 AM »
Turns out I was seriously overcomplicating things.

There was no need to store anything in a vector whatsoever.
For anyone who ever has this issue:

1) If your bullets spawn on an object that has rotation, they will rotate to the correct direction when spawned. You then just have to apply force to the bullet in the x direction.
2) If your bullets spawn on an empty object just infront of your object with rotation, you'll forever wallow in despair, and you'll want to kill yourself.

Just make your bullet spawn on the enemy, and adjust the collision you're using so that the collision mesh doesn't spawn directly ontop of the enemy's collision mesh.