playMaker

Author Topic: Please help with this vector rotation [SOLVED]  (Read 3676 times)

uberwolfe

  • Junior Playmaker
  • **
  • Posts: 59
    • View Profile
Please help with this vector rotation [SOLVED]
« on: September 08, 2013, 06:07:35 AM »
So everything always seems to be moving ahead nicely until I have to play with vectors and other complex math stuff. It reminds me I'm an artist by trade, not a programmer lol.

I have a prototype tank that aims at a wherever the mouse is on my terrain using the Smooth Look At Direction action. This works nicely.

The problem I have is with the rotation of the turret on slopes. I just want the tank to rotate its turret around its local Y axis.

Hopefully these pics will detail it better:


This shows the problem. The turret clips through the tank when trying to rotate on slopes, this happens wether I have the Keep Vertical on or off.

Below is what it should look like, regardless of angle of slope or position of the mouse. The turret only rotates around it's local Y axis:


I know the answer lies in some vector equation that completely eludes me..

How do I use the Smooth Look actions yet keep the rotation only on the local Y axis..?? sorry If I haven't explained well.
« Last Edit: September 09, 2013, 04:24:56 AM by uberwolfe »

uberwolfe

  • Junior Playmaker
  • **
  • Posts: 59
    • View Profile
Re: Please help with this vector rotation :(
« Reply #1 on: September 09, 2013, 01:53:37 AM »
nobody has any idea how this could be done?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14692
  • Official Playmaker Support
    • View Profile
Re: Please help with this vector rotation :(
« Reply #2 on: September 09, 2013, 03:50:04 AM »
Hi,

 Here we go: I modified the lookAt action, created a new one called, LookAt2 and it has a new check box "Constraint locally" which in effect makes the "keep vertical" option local, instead of global.


I've attached a fully working example. You'll note that you do need to pass the "up" vector, which is in this case always the vertical axis of the turret.


Bye,

 Jean
« Last Edit: September 09, 2013, 03:53:41 AM by jeanfabre »

uberwolfe

  • Junior Playmaker
  • **
  • Posts: 59
    • View Profile
Re: Please help with this vector rotation :(
« Reply #3 on: September 09, 2013, 04:24:09 AM »
Jean, you are an absolute champion - this works perfectly!

Where do I send the beer? haha :)

Thank you so much for this, couldn't have asked for more!!
« Last Edit: September 09, 2013, 04:37:45 AM by uberwolfe »