playMaker

Author Topic: Get speed for Object in the local derection Z [SOLVED]  (Read 5064 times)

Harvid

  • Playmaker Newbie
  • *
  • Posts: 23
Get speed for Object in the local derection Z [SOLVED]
« on: May 02, 2015, 07:45:12 PM »
Hey

Is it possible to Get Speed for non-rigid bodies, similar to GetGameObjectSpeed.cs:
just in the local "self" derection.
I want to measure the speed of a object in the look at direction z

And if there is some another way of doing that please let me know :)

Isak
« Last Edit: May 07, 2015, 07:40:44 AM by Harvid »

Digitom

  • Junior Playmaker
  • **
  • Posts: 61
Re: Get speed for Object in the local derection Z
« Reply #1 on: May 02, 2015, 08:01:37 PM »
you coudl make a state machine that stores the current position, waits a certain amount of time...FINISH transition to the next state.

Next state you store current position#2, distance from last position, store distance as a float, after a certain amount of time, switch back to the first state....which would store the distance again.

This would just loop. over and over. You would then get a distance per time.

kind of a hack way of doing it...kinda weird how an object NEEDS a rigidbody to do the simple math.

Harvid

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Get speed for Object in the local derection Z
« Reply #2 on: May 02, 2015, 08:30:29 PM »
Sorry i don't understand, won't it just given me the world position/speed, and not the local speed in one axies
« Last Edit: May 02, 2015, 08:36:01 PM by Harvid »

Digitom

  • Junior Playmaker
  • **
  • Posts: 61
Re: Get speed for Object in the local derection Z
« Reply #3 on: May 02, 2015, 08:37:08 PM »
you would be measuring the DISTANCE from vector3 to vector3.

This gives you the Distance per time.

Digitom

  • Junior Playmaker
  • **
  • Posts: 61
Re: Get speed for Object in the local derection Z
« Reply #4 on: May 02, 2015, 08:42:04 PM »
pic attached

Digitom

  • Junior Playmaker
  • **
  • Posts: 61
Re: Get speed for Object in the local derection Z
« Reply #5 on: May 02, 2015, 08:43:23 PM »
if you just want one axes you need to change the math around a little bit. But it would be the same concept.

Harvid

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Get speed for Object in the local derection Z
« Reply #6 on: May 04, 2015, 05:45:17 PM »
Thanks for the idea but i can't get the vector 3d operator to give me any distance value :-\
screenshot in debug mode

Digitom

  • Junior Playmaker
  • **
  • Posts: 61
Re: Get speed for Object in the local derection Z
« Reply #7 on: May 04, 2015, 08:07:21 PM »
distance will only get you a float value.

what you can do is store the position of the z axis ...store it as a Vector3

so Pos1 = 0,0,Z     Pos2 = 0,0,Z

than you get the distance between the two vector3 variables. This would get the speed in the Z axis.

Although this would not be the local Z...it would be world.

Harvid

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Get speed for Object in the local derection Z
« Reply #8 on: May 04, 2015, 09:05:40 PM »
Annoying am not aloud to store the distance in a vector3, like distance from XtoX YtoY ZtoZ...

I really need the local speed in the Z axis. Any other ideas  ;)
« Last Edit: May 04, 2015, 09:08:53 PM by Harvid »

Digitom

  • Junior Playmaker
  • **
  • Posts: 61
Re: Get speed for Object in the local derection Z
« Reply #9 on: May 04, 2015, 09:32:34 PM »
make an empty child object and play around with  the 'transform direction' and 'inverse transform direction' actions.

I think these actions should get what you are looking for.

Harvid

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Get speed for Object in the local derection Z
« Reply #10 on: May 04, 2015, 10:01:40 PM »
inverse transform direction ? how i understand it is it only possible to transform local to world, i think i need the opposite somehow

Harvid

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Get speed for Object in the local derection Z
« Reply #11 on: May 07, 2015, 07:40:15 AM »
Update of the script GetGameObjectSpeed.cs so it's contains a option for "self" local axis.