playMaker

Author Topic: 1.1 Bug - iTweenMoveTo in local space [FIXED]  (Read 10189 times)

Proton

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • NPlay
1.1 Bug - iTweenMoveTo in local space [FIXED]
« on: July 21, 2011, 10:51:51 PM »
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.
« Last Edit: November 05, 2011, 02:23:14 PM by alexchouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3632
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #1 on: July 22, 2011, 09:51:15 AM »
Thanks for the bug report - and fix!

Proton

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • NPlay
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #2 on: July 22, 2011, 10:13:05 AM »
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.

Razieln64

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #3 on: August 03, 2011, 04: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]
« Last Edit: August 03, 2011, 05:03:20 PM by Razieln64 »

Proton

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • NPlay
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #4 on: August 03, 2011, 06: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!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3632
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #5 on: August 03, 2011, 06:09:45 PM »
Proton, would you mind emailing or posting the complete fixed version. Want to include it in the update. Thanks!

Proton

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • NPlay
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #6 on: August 03, 2011, 08: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.
« Last Edit: August 03, 2011, 08:05:21 PM by Proton »

Razieln64

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #7 on: August 04, 2011, 05: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

Razieln64

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: 1.1 and 1.2 Bug - iTweenMoveTo in local space
« Reply #8 on: September 10, 2011, 12: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
« Last Edit: September 10, 2011, 12:26:17 PM by Razieln64 »

tobbeo

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 186
    • View Profile
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #9 on: September 10, 2011, 03: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.

Razieln64

  • Playmaker Newbie
  • *
  • Posts: 21
    • View Profile
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #10 on: September 11, 2011, 07: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.  ;)
« Last Edit: September 11, 2011, 07:46:58 AM by Razieln64 »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3632
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: 1.1 Bug - iTweenMoveTo in local space
« Reply #11 on: September 11, 2011, 03: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...

inert

  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
Re: 1.1 Bug - iTweenMoveTo in local space [FIXED]
« Reply #12 on: October 22, 2012, 03: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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14684
  • Official Playmaker Support
    • View Profile
Re: 1.1 Bug - iTweenMoveTo in local space [FIXED]
« Reply #13 on: November 04, 2012, 11:27:28 PM »
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