playMaker

Author Topic: 2d Rotating Turret Bullet Direction [SOLVED]  (Read 2799 times)

HeathClose

  • Full Member
  • ***
  • Posts: 226
2d Rotating Turret Bullet Direction [SOLVED]
« on: August 08, 2017, 03:22:23 PM »
I have this very simple 2d rotating turret.



I has a look at 2d action on it so it tracks the player.

I have the bullets in Poolboss, and when the turret is tracking the player, it has coregamekit spawn action to spawn the bullets.

I'm having trouble figuring out how to get the bullet to fire in the direction of the player.  I've tried set velocity 2d.  I've tried add force 2d.  I've tried add relative force 2d.  Nothing seems to work on moving the bullet in the direction the barrel of the turret is facing when it fires.
« Last Edit: August 09, 2017, 11:15:11 AM by HeathClose »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: 2d Rotating Turret Bullet Direction
« Reply #1 on: August 08, 2017, 09:45:36 PM »
Hi,
It can be several things.
is the bullet moving at all?

Is the object select?

Do you have a (empty object) spawn point on the barrel to set the postion and rotation when a bullet is spawned.

Try using breakpoints to see where it goes wrong (right click on a state and select 'Toggle Breakpoint')

Maybe some settings on the rigidbody (kinematic, constrains,drag )

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2d Rotating Turret Bullet Direction
« Reply #2 on: August 09, 2017, 04:03:08 AM »
Hi,

 you need to use the action "GetDirection", you get the direction of the turret, you then normalize that direction using (Vector3Normalize) to get a unit vector of that direction, multiply it by a speed coef use "Vector3Multiply" and set the velocity of your bullet using "SetVelocity" to this value you got with the above as soon as you spawned your bullet.

 Bye,

 Jean

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: 2d Rotating Turret Bullet Direction
« Reply #3 on: August 09, 2017, 10:52:24 AM »
The only get direction i see is a ugui action.  I don't see get direction on the ecosystem either.

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: 2d Rotating Turret Bullet Direction
« Reply #4 on: August 09, 2017, 11:07:42 AM »
Actually... I got this working with the following fsm on the bullet

I tried many variations of this yesterday, trying to get angles and whatnot... but it never dawned on me to just have the bullet look at the player and take off.  The relative action makes this work.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2d Rotating Turret Bullet Direction [SOLVED]
« Reply #5 on: August 10, 2017, 03:01:54 AM »
Hi,

 sorry, it was "transformDirection" and it's a action already with PlayMaker :)

 Bye,

 Jean