PDA

View Full Version : MoveToFrame - with rotation [Cross post from Hub]



Giraffe
11-15-2005, 09:20 AM
[Originally posted on the Hub: http://www.jkhub.net/forums/viewtopic.php?t=349 ]

When I try to use MoveToFrame() to move an object between two frames that also has a rotation, the thing moves between the two frames and THEN rotates when it gets there.

Is anyone aware of why this effect occurs and anything I might be able to do to avoid the problem?

zagibu
11-15-2005, 03:20 PM
I think there is a cog command to rotate objects. I'm too lazy to verify, but if it's true, you should make the frames without rotation, then apply the rotation with said command.

gbk
11-15-2005, 05:25 PM
Post your code.

Reid
11-15-2005, 08:16 PM
goRotate(); I think

Giraffe
11-16-2005, 03:28 AM
cog:

# Jedi Knight Cog Script
#
# Asteroid Controller
#
# Sets up the asteroids to float across space
#
# Giraffe
# 28/10/2005
# ======================

symbols

thing ghostthing
template asteroidtemplate
thing asteroidthing local

int wormholeexitframe
int wormholeentryframe
int wormholewarpsourceframe
int wormholewarpdestframe

flex wormholespeed
flex normalspacespeed

int state local

message startup
message arrived

end

code

startup:
state = 0;
asteroidthing = CreateThing(asteroidtemplate, ghostthing);
AttachThingToThing(asteroidthing, ghostthing);
MoveToFrame(ghostthing, wormholeexitframe, wormholespeed);
return;

arrived:
if (state == 0)
{
state = 1;
MoveToFrame(ghostthing, wormholeentryframe, normalspacespeed);
}
else if (state == 1)
{
state = 2;
MoveToFrame(ghostthing, wormholewarpsourceframe, wormholespeed);
}
else if (state == 2)
{
state = 3;
DestroyThing(asteroidthing);
MoveToFrame(ghostthing, wormholewarpdestframe, 100);
}
else if (state == 3)
{
state = 0;
asteroidthing = CreateThing(asteroidtemplate, ghostthing);
AttachThingToThing(asteroidthing, ghostthing);
MoveToFrame(ghostthing, wormholeexitframe, wormholespeed);
}
return;
end

The Create/Attach/Destroy code is there so that I can move the object straight back to the warpdestframe without it going through all the intervening frames. I tried using a combination of SkipToFrame and JumpToFrame, but that doesn't update the frame the object is actually on, so when it then moves to the next frame, it first off all moves to the frame next to the warpsourceframe and then all the intervening frames back to the first frame, and THEN movese to the frame it's heading for.

The .jed file has the following properties on the ghosthing object:

THINGFLAGS=0x400048
NUMFRAMES=10
FRAME=(5/1/0:0/0/0)
FRAME=(2.75/2/0:0/337.38/0)
FRAME=(1.934/2.491/0:0/320.535/-10)
FRAME=(1.296/3.197/0:0/303.069/-20)
FRAME=(.889/4.058/0:0/286.845/-30)
FRAME=(.75/5/0:0/270/-40)
FRAME=(.889/5.942/0:0/253.155/-50)
FRAME=(1.296/6.803/0:0/236.31/-60)
FRAME=(1.934/7.509/0:0/219.465/-70)
FRAME=(2.75/8/0:0/202.62/-80)

The template being used is:

# DESC:
# BBOX: -.7 -.72 -.53 .79 .63 .37
ast_01 _walkstruct size=1.00396 movesize=1.00396 model3d=ast01.3DO