Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ryf9059 on June 07, 2013, 12:43:59 AM

Title: position before and after the translation in the same frame
Post by: ryf9059 on June 07, 2013, 12:43:59 AM
I try to recored the position of an object before and after the translation within the same frame, but they appear to be exactly the same in the inspector.

I have 2 vector3 called currentPosision and lastPosition. I first use getPosition to store the current position of the object into lastPosition, and them use translate, so now the object should be moved along with the translation vector, I then use getPosition again and store the position after the translation in the currentPosition.

So now the difference between last position and current position should be the traslated value. But it turns out the currentPosition and the lastPosition are having the exact same value in the inspector. But the object did move in the game view.

Why is this? Did I miss something?
Title: Re: position before and after the translation in the same frame
Post by: jeanfabre on June 07, 2013, 01:02:23 AM
Hi,

 Yes, glancing over the values in the inspector make you think so, but the catch is that you will perform operation before the gets equal.

1: store the position of the gameObject in "Current Position"
2: store the substraction the "current position" to the "previous position" in "delta" ->>> they are not equal if the user moved
3: store the "current position" into the "previous" position ->> NOW they are equal

step three is important because on the next frame, just prior step 1, "current position" and "previous" position are still equal, until step 1.

does that make more sense?

bye,

Jean