Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Harvid on May 02, 2015, 07:45:12 PM

Title: Get speed for Object in the local derection Z [SOLVED]
Post by: Harvid 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
Title: Re: Get speed for Object in the local derection Z
Post by: Digitom 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.
Title: Re: Get speed for Object in the local derection Z
Post by: Harvid 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
Title: Re: Get speed for Object in the local derection Z
Post by: Digitom 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.
Title: Re: Get speed for Object in the local derection Z
Post by: Digitom on May 02, 2015, 08:42:04 PM
pic attached
Title: Re: Get speed for Object in the local derection Z
Post by: Digitom 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.
Title: Re: Get speed for Object in the local derection Z
Post by: Harvid 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
Title: Re: Get speed for Object in the local derection Z
Post by: Digitom 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.
Title: Re: Get speed for Object in the local derection Z
Post by: Harvid 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  ;)
Title: Re: Get speed for Object in the local derection Z
Post by: Digitom 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.
Title: Re: Get speed for Object in the local derection Z
Post by: Harvid 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
Title: Re: Get speed for Object in the local derection Z
Post by: Harvid on May 07, 2015, 07:40:15 AM
Update of the script GetGameObjectSpeed.cs so it's contains a option for "self" local axis.