Page 1 of 1

Frame stitching

PostPosted: Tue Feb 07, 2006 2:27 am
by game_mate
I am triing to make an overhead hovercraft game.My problem is the motor mounted on the rear is parented to the body.I would like to make the motors frame number = the bodys frame number so that they follow in 360 degrees reletive to one another. Frames for each are every 10 degrees. Does anyone know a script that would HELP.
thanks
Game_Mate

PostPosted: Tue Feb 07, 2006 8:06 am
by unigamer
Create a variable for the parent and set it to animpos:

current_frame = animpos;

And on the motor set:

animpos = current_frame;



This code may not work because I'm fairly new to Game Editor but I'm pretty sure the rough idea is right.

Frame stitching 2

PostPosted: Tue Feb 07, 2006 4:42 pm
by game_mate
That worked for the frames, but is there a way to make the motor follow the ark of the hover craft wile maintaining the ability to change frames if i want that event to happen. If anyone knows a way to script that pleas help

PostPosted: Tue Apr 04, 2006 2:20 am
by DilloDude
Add the following in global code:
Code: Select all
float d2R(int degrees)
{
    return degrees * (3.1415926535897932384626433832795 / 180);
}

double xdist(int deg, double dist)
{
    return  dist * cos(d2R(deg));
}

double ydist(int deg, double dist)
{
    return -dist * sin(d2R(deg));
}

Now, in draw actor->motor:
Code: Select all
x=hover.x;
y=hover.y;
x+=xdist(angle between hovercraft and motor(hovercraft.angle-180), distance from hovercraft center);
y+=ydist(angle between hovercraft and motor(hovercraft.angle-180), distance from hovercraft center);

This is useful for anything where an actor should be a certain distance from another. My brother helped me make it for creating a shot at the end of a cannon's barrel, and I modified it to make two functions.

Another way that solves some problems is to make the animation rotate around a central point.