playMaker

Author Topic: 2d Turret firing.  (Read 691 times)

FrankDePaul

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
2d Turret firing.
« on: February 09, 2018, 07:42:59 PM »
I have looked through the forums and still cant get this to work. I have turrets that rotate on the Z axis. There are a lot of them. I have them rotating to track enemies. The issue I am running into is bullet firing.

I can spawn bullets, but unsure of what functions to use to have them travel in the direction the turret is facing. I can affect the rotation of the bullet object graphic, but not the direction it flies.

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 61
    • View Profile
Re: 2d Turret firing.
« Reply #1 on: February 10, 2018, 01:02:03 AM »
you could ray cast to there end distance location or you could get the facing of the turrent then move bullet in that direction each frame.

FrankDePaul

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: 2d Turret firing.
« Reply #2 on: February 10, 2018, 08:03:25 AM »
How would I go about getting the facing of the turret. I can't seem to find an action for that. I am a bit of a beginner to playmaker. I can see how to do it in 3d, but 2d on the Z axis seems a bit more complicated.

Thanks!

FrankDePaul

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: 2d Turret firing.
« Reply #3 on: February 10, 2018, 09:56:26 AM »
To add to this, does anyone know of a Raycast tutorial using fast bullets. I can fire shots in the correct direction now, but they lag behind. I can speed the bullet up a bit and offset the turret rotation, but I think raycasting might be a better idea.

antibob

  • Playmaker Newbie
  • *
  • Posts: 24
    • View Profile
    • BillsClass
Re: 2d Turret firing.
« Reply #4 on: February 10, 2018, 07:49:17 PM »

I have a 2D shooter project in the works and used a couple of different solutions.

One is to get the speed or velocity of the turret and add it to the bullet along with the speed, velocity or force of the bullet. You can use the Add Relative Force action.

To get the direction of a Vector2D I use a "projectile spawn" empty game object as a child of a the "turret". The spawn is offset in the forward position infant of the turret and set as a child of turret. Subtract the Projectile_Spawn from the Turret_Position to get your direction. Add a multiplier to the result and use it for 2D Add Force and you should be in business.

Here is screenshot.


FrankDePaul

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: 2d Turret firing.
« Reply #5 on: February 10, 2018, 10:59:11 PM »
Thanks! Got it working