Game Development Community

Preserving object rotation on mount? (solved)

by Ben Shive · in Torque Game Builder · 08/03/2006 (6:04 pm) · 4 replies

I'm successfully chaining multiple objects together with a 'mount', but I'm stuck on another mount-related problem.

When snapping multiple objects together, they will all rotate together correctly with trackRotation true. What I don't see an easy way to change is preserving the rotation of the object snapped to the parent.

Right now:
Object A is rotated 0.
Object B is rotated 90.
Object A gets snapped to Object B.
Both A and B are now rotated 0.

What I want is A still 0 and B mounted at 90, and if A gets rotated 90, B will be at 180.

I making sense?

#1
08/04/2006 (11:05 am)
There's a rotation property in mounting that I think is _supposed_ to do this though I don't think it really works. However from my tests, if you have an object rotated before mounting, it should keep it's original rotation and be offset by TrackRotation accordingly?
#2
08/04/2006 (6:21 pm)
The only thing I see in the mount() documentation related to the rotation is the trackRotation property which is just a true/false. If I leave it false, the mounted object's rotation is preserved. However, when I rotate the object it's mounted to the orientation stays the same. I can get get one or the other of the behaviors I want, but not both.

What I'm currently using:
$activeObj::selectedObj.mount(
					%targ,
					getWord(%localPt, 0) - getWord(%localPtOffset, 0),
					getWord(%localPt, 1) - getWord(%localPtOffset, 1),
					0, 	// force
					true, 	// trackRotation
					true,	// sendToMount
					false,	// ownedByMount
					false);	// inheritAttributes
#3
08/04/2006 (6:39 pm)
Further investigation reveals that it's not aligning to the mount's rotation. It's applying the rotation of the mount target to the object that's getting mounted. I'm not changing the rotation at all between each mount - dismounting and re-mounting.

After mount results
A - getRotation of the object that's being mounted
B - getRotation of the object that A's being mounted to

A B
0 270
270 0
270 270
180 270
90 270
270 0

It's late, so I'm probably not seeing something at this point ...
#4
08/05/2006 (12:01 pm)
Fixed, with a 'duh' momment. Still seems hackish to me since I wouldn't expect the act of mounting to change the rotation on the mount call.

I just offset the rotation of the mounting object by the target's rotation so the change would be zero.