problem tweening rotationY of character demo character.ghostObject

Software: Away3D 4.x

hfeist, Jr. Member
Posted: 12 March 2014 04:42 PM   Total Posts: 37

I’m using the code in the character demo as the starting point of a simulated first-person walkthrough of an art museum.

Everything works well so far but I’m having a problem finding a way to smoothly tween the camera’s rotation.

When visitors click on a painting I need them to tween x and z over to that location, be placed facing it and standing back a viewable distance. All of this has been worked out and works well except for one annoying problem.

If the painting is on a wall that is facing at right angles from the direction the visitor is facing when they click, the camera sometimes ends up facing backwards or 180 degrees from the painting.

This tween gets the visitor to the right place in from of the painting:

Tweener.addTween(character.ghostObject{x:posxz:posztime:3transition:"easeout"}); 

Then the code below works well some of the time but not always:

The var p is the pan angle needed to face the painting from that final position.

Tweener.addTween(character.ghostObject,{rotationY:p0,time:2transition:"easeout",onComplete:function():void { character.ghostObject.rotation = new Vector3D(1,p,0)}}); 

The onComplete function is there as a crude solution to correct the rotation in cases where it’s wrong. Any ideas how I might solve this?

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 12 March 2014 05:15 PM   Total Posts: 669   [ # 1 ]

what’s p0? At the end you turn to p, in the tween to p0.

 

   

hfeist, Jr. Member
Posted: 12 March 2014 07:02 PM   Total Posts: 37   [ # 2 ]

Well that’s odd. I corrected that error but it didn’t take. Even now the edit doesn’t work.

Anyway it should be p0 instead of p0—screen grab attached

 

   

hfeist, Jr. Member
Posted: 12 March 2014 07:09 PM   Total Posts: 37   [ # 3 ]

Now that’s frustrating! This editor doesn’t like the percent symbol.

it should read p (percent symbol) 180—screen grab attached

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X