playMaker

Author Topic: Turret Rotation & Smooth Look  (Read 63 times)

j1knight5

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Turret Rotation & Smooth Look
« on: January 10, 2019, 11:33:34 AM »
Hey folks -

So I'm pulling my hair outta my head on this one and I figured I'd ask for help.  I'm building a 2-stick shooter game with a hover tank & turret.  As with most games, the Left stick handles steering & thrust and the Right stick handles aiming & shooting. 

Using Control Freak2, I'm able to get on-screen control sticks up easily for both movement and shooting, correlating to the Tank game object and child turret game object.  I’ve created an FSM on the turret for aiming & shooting and I'm able to use the Get Axis actions to pull the vector3 from the Left stick Axis inputs (H2 & V2).  The input vector3 is then sent to a Smooth Look At Direction action, to rotate the turret and aim in the direction the stick is pointing at.  I'm also able to tweak the speed in which the turret spins by adjusting the Smooth Look at speed.

I’m having a problem with the fire controls and controlling when the turret fires. 

Firing of the turret is based on TOUCH – when the player touches the stick and moves it in any direction, the turret will fire repeatedly (e.g. a machine-gun).  This separate Fire Control FSM for this shooting behavior is also on the turret came object.

As firing bullets is tied to TOUCH (e.g. when the player touches the stick and moves it in any direction, the turret fires), the Turret will immediately fire when the stick is touched.  The problem I’m running into is that I’d like the Turret to not fire until it has rotated to the direction in which the stick is pointed.

(e.g. the stick touched and pointed downward, the turret rotates to match the angle in which the stick is pointed, and once the turret reaches that angle it initiates firing of bullets)


Is there a way to extrapolate the Y rotation float from the vector3 angle that’s saved from the Get Axis Event (being used to get the stick direction before being sent to Smooth Look At Direction) and then compare that value to the Y of the Turret’s rotation transform?  (and I noted that the Y rotation transform is not a 360-degree value but a +/-180-degree value)  I assume if I can get both values as floats, I can do a Float Compare (with a level of Tolerance) to trigger when the Turret can fire.


And plain non-coder help, por favor..  (For the life of me, when I see terms like Quaternions, I think ST:TNG Q versions of He-Man)   :D

Thanks!!

Athin

  • Junior Playmaker
  • **
  • Posts: 66
    • View Profile
Re: Turret Rotation & Smooth Look
« Reply #1 on: January 12, 2019, 02:14:13 AM »
Not sure if you notice it (or if I read your issue wrong) but on the smooth look at direction action there is a FINISH event you may be able to use.  I believe it will only fire off that event once the object is done turning towards the target. Then from there, you can start the firing events for the gun to shoot.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13732
  • Official Playmaker Support
    • View Profile
Re: Turret Rotation & Smooth Look
« Reply #2 on: January 14, 2019, 12:39:12 AM »
Hi,

 I think your solution is to first make sure you can make the different between a touch and a drag.

once you have this difference, you can rewire your logic to not fire when you drag.

 can you detect already that you are dragging or not? normally you should have something to tell you the drag has ended.

Bye,

 Jean