PDA

View Full Version : Rotation and Matrices Help



Nejuf
November 23rd, 2009, 02:14 PM
Hello,

I am using Corey Oneil's collision detection kit, but I am having a problem with rotation.

In my code I have:

myItem.rotationY = 180;

However, during a collision detection, having it rotated like this causes an error with this line:

transMatrix1.concat(currentObj.parent.transform.ma trix);

The error is simply "Error #1009: Cannot access a property or method of a null object reference."

I have not really worked with matrices and rotation so if someone could help me that would be great. Do I need to make a matrix rather than just doing the rotationY or should I change something else? I cannot manually change the movie clip because it throws off the animation and armatures.

Thanks.

IQAndreas
November 23rd, 2009, 02:57 PM
That means that either currentObj, currentObj.parent, or currentObj.parent.transform is null.

My guess is that currentObj.parent is null, meaning the item isn't on the stage. ;) Try making sure it is a child of something first.

skineh
November 23rd, 2009, 03:17 PM
*steps into the Way-Back Machine*

I wrote the CDK targeting Flash Player 9, so if I had to guess, I'd say the null value is the matrix. Since you set rotationY, the object's matrix3d is used, and its matrix is nulled. I don't do much FP10 work, so maybe someone can confirm/refute that's what happens when you do 3D transforms in FP10.

If that is the case, then you're up a creek with the CDK as-is, since it doesn't take any FP10 stuff into consideration. Writing a FP10 version of the CDK has been on my wishlist for awhile, but both professional and personal work have me swamped in other areas.

IQAndreas
November 23rd, 2009, 04:02 PM
Ah. Yes.

It was changed to "matrix3d", but I believe you can still access the "matrix" property as long as your DisplayObject doesn't have any 3d settings set, but I could be wrong...

Nejuf
November 29th, 2009, 11:03 PM
Thanks so much for the help :thumb:.

I first tried switching over to FlashPlayer 9. However, because of that, the rotationY doesn't work. I ended up switching the way I transformed the object to do scaleX to be negative. The FlashPlayer and the CDK seem to be happy with this so thanks again.