playMaker

Author Topic: Turret Rotation  (Read 2144 times)

JM9721

  • Playmaker Newbie
  • *
  • Posts: 2
Turret Rotation
« on: October 05, 2014, 03:52:18 AM »
I have been trying to make a auto turret in Unity with Playmaker for a couple of days and I have gotten nearly everything to work except rotation... The problem is that the base rotates just fine but the barrel can't seem to want to point only up in the Z angles it will with [iTween/Vector Angle/Look at/etc] start turning whatever way it wants to even on those with axis limits and trying every option. I had the idea to use distance from the turret to object and create an empty child at even height with the turret to calculate the angle using Trig(distance from turret-object=hypotenuse, and turret-object's child=adj/opp + right angles etc) but I can't find anything to do such.

So I was wondering if anyone knows of a Trig calculator for Playmaker or a way to limit the turrets barrels to Z angle rise only(while pointing at object).

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Re: Turret Rotation
« Reply #1 on: October 05, 2014, 05:16:46 AM »
You haven't told what you want your turret to do, only what it does.  ;)
If you want your barrel to point at an enemy, you can use iTween Look To, which allows you to take the transform of your enemy and turn the turret to "look" in that direction. You can even restrain certain axis to prevent the barrel from pointing up, fx.
Just notice that you need to have the barrel object "zeroed" axis wise, before mounting it on your base.
The Force is with you, young Playmaker – but you are not a C# senpai yet.

JM9721

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Turret Rotation
« Reply #2 on: October 05, 2014, 01:34:12 PM »
I got it working after I found ( https://hutonggames.fogbugz.com/default.asp?W971 ) a Trigonometry package for Playmaker + 5minutes of work^^
Thanks a bunch Jeanfabre, your awesome!!^^

btw I don't suppose their is a way to grab all my states/actions and create a turret custom action is their? Or would I have to tear apart code to do that?
« Last Edit: October 05, 2014, 01:38:38 PM by JM9721 »