Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: Proton on July 22, 2011, 01:51:51 AM

Title: 1.1 Bug - iTweenMoveTo in local space [FIXED]
Post by: Proton on July 22, 2011, 01:51:51 AM
Reproduction Steps
1. Add iTweenMoveTo action to a child game object
2. Setup the action to animate for a few seconds
3. Make sure the action's 'Space' = 'Self'
4. Run program
5. Drag the parent game object around the scene

Expected Behavior
The animated child continues to move with the parent since it should only animate in local space.

Actual Behavior
The child animates in world space and does not get dragged with the parent.



iTweenMoveTo.cs
Line 129

Quote
hash.Add("space", space);
hash.Add("islocal", space == Space.Self );

Based on iTween documentation. Seems like sometimes they use 'space', other times 'islocal'.
http://itween.pixelplacement.com/documentation.php#MoveTo

iTweenMoveTo.cs
Line 153

Quote
else tempVct3[tempVct3.Length - 1 - i] = transforms.Value.transform.position + (vectors.IsNone ? Vector3.zero : vectors.Value);
else tempVct3[tempVct3.Length - 1 - i] = (space == Space.World ? transforms.Value.transform.position : transforms.Value.transform.localPosition) + (vectors.IsNone ? Vector3.zero : vectors.Value);
Line 161 (For the non-reversed path)
Quote
else tempVct3[tempVct3.Length - 1 - i] = transforms.Value.transform.position + (vectors.IsNone ? Vector3.zero : vectors.Value);
else tempVct3[tempVct3.Length - 1 - i] = (space == Space.World ? transforms.Value.transform.position : transforms.Value.transform.localPosition) + (vectors.IsNone ? Vector3.zero : vectors.Value);


The following classes should also use 'islocal' instead of 'space':
iTweenMoveFrom.cs
iTweenMoveUpdate.cs
iTweenRotateFrom.cs
iTweenRotateTo.cs
iTweenRotateUpdate.cs


Edit: One other thing, 'Move To Path' = true does not work when Space = Self. I think it might be an iTween bug though, not sure. The first path node it generates seems to be in world space.
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Alex Chouls on July 22, 2011, 12:51:15 PM
Thanks for the bug report - and fix!
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Proton on July 22, 2011, 01:13:05 PM
I just realized that for the path & target nodes we can't just use their localPosition since they might not have the same parent as the original GameObject.

So it might need to look something like this:
Quote

pos = space == Space.World ? transformPosition.Value.transform.position + pos : go.transform.parent.InverseTransformPoint(transformPosition.Value.transform.position) + pos ;
 
Quote

else tempVct3 = (space == Space.World ? transforms.Value.transform.position : go.transform.parent.InverseTransformPoint( transforms.Value.transform.position) ) + (vectors.IsNone ? Vector3.zero : vectors.Value);
 

This doesn't take into account the situation where 'go' does not actually have a parent (local space == world space). So a check or perhaps validation would be required at the start of DoiTween:
Code: [Select]
if( space == Space.Self && go.transform.parent == null ){
space = Space.World;
}

Although the issue I noted with 'Move To Path' may imply that iTween expects the world position should always be used for path & target nodes, but that seems strange to me.
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Razieln64 on August 03, 2011, 07:46:28 PM
Proton, just to let you know that you forgot to include an array index for the transforms array in your solution to repairing the code.

This won't compile because no array index is specified.
Code: [Select]
[color=red]transforms.Value.transform.position[/color]
This will compile.
Code: [Select]
[color=green]transforms[i].Value.transform.position[/color]
There's the same problem with the vectors array. You have to specify an index or it won't compile.
Code: [Select]
[color=red]vectors.IsNone[/color]
This will work.
Code: [Select]
[color=green]vectors[i].IsNone[/color]
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Proton on August 03, 2011, 09:07:11 PM
That is so strange, my local code looks like yours (with the index).

I'm not sure how I could have copied and pasted with that mistake so many times. I also see that I wrote 'else tempVct3[tempVct3.Length - 1 - i]' instead of 'else tempVct3' for the non-reversed version.

Thanks for the catch!
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Alex Chouls on August 03, 2011, 09:09:45 PM
Proton, would you mind emailing or posting the complete fixed version. Want to include it in the update. Thanks!
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Proton on August 03, 2011, 11:03:11 PM
Figured out what happened, since I used 'quote' instead of 'code' it encoded some of my text.

Noticed my last post became italic towards the end, that would be the index '[ i ]' which also works as italicize on the forum.

I've attached the modified file.
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Razieln64 on August 04, 2011, 08:44:01 PM
You were right about the RotateTo not working in local space.
Here's the modified code at line 76:

Change
Code: [Select]
[color=red]"space", space[/color] 
To
Code: [Select]
[color=green]"islocal", space == Space.World ? false : true[/color]
Local rotation will now work fine.  :D
Title: Re: 1.1 and 1.2 Bug - iTweenMoveTo in local space
Post by: Razieln64 on September 10, 2011, 03:22:00 PM
Why has this not been changed in 1.2?  ??? The bugs just overwrote themselves when I imported 1.2 over 1.1.1! Please make sure to fix this action in 1.2.1
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: tobbeo on September 10, 2011, 06:10:20 PM
Hey, it's easy to miss some things sometimes. Especially with a huge update like this one. Just send Alex a friendly reminder. Also, keep in mind that it could also be an issue with iTween. Try to take a look at the action yourself. Even without much scripting experience, iTween scripting is super easy with some googleing.
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Razieln64 on September 11, 2011, 10:42:07 AM
It's not a big deal, but since the fix is in this thread and Alex answered to it I thought it would be included in the 1.2 update. I changed the action myself. This is not the case for everyone who owns Playmaker. At first I wasn't so happy that my FSMs we're not working normally after the 1.2 update.

I had a backup. It will take me a day or two to recheck everything, but the global variables feature out weights the time to adapt my FSMs to the new version.  ;)
Title: Re: 1.1 Bug - iTweenMoveTo in local space
Post by: Alex Chouls on September 11, 2011, 06:32:53 PM
Sorry about that, I had fixed it locally, but there was an error in the build script (copying action subdirectories). Will be fixed in the next update...
Title: Re: 1.1 Bug - iTweenMoveTo in local space [FIXED]
Post by: inert on October 22, 2012, 06:18:48 AM
Hi,

I know the last reply was over a year ago, but I was wondering if anyone knows if this fix can be applied to the standalone version of iTween too, and if so, how?


Thanks
Title: Re: 1.1 Bug - iTweenMoveTo in local space [FIXED]
Post by: jeanfabre on November 05, 2012, 01:27:28 AM
Hi,

 you should contact iTween directly I think, if you can report a bug on the standalone build.

tho this problem is really related to PlayMaker usage of iTween, how does that related to the standalone version of iTween? can you explain what's your problem?


bye,

Jean