I am currently working on a script to include in my games that can be used as a substitute for traditional motion functions. 2D motion wasn't so hard... I even found a more efficient way to do it since I started, but 3D... In case you don't quite understand the gravity of this endeavor, think of a flight simulator that lets you go all over the place. Yaw, Pitch, Roll... the whole thing. Ever play Star Wars: Battlefront 2? Ever play a space battle, get in a star fighter and rip and tear all over the place at every angle??? Well, I need something that does that.
There are a few challenges: Rotation on the X axis and the Y axis, properly incrementing the values (you don't move forward as fast the more you climb. in fact, climb far enough and your direction changes by 180 degrees (and when you roll, you see a similar effect on how steep your climb angle is... and depending on the roll angle, climbing could change your direction + or -45 degrees, etc)). It's been pretty tricky so far, but it's coming along. I suppose that, if I have a question here, I have two:
1. If you're interested in this, say so. I don't mind sharing my results.
and
2. Did someone do this, already? Because I could find better usage for my time than re-doing something that's already done.
I've included a little code to let you know that I mean business. I know a lot of people hesitate to comment on topics like these for fear that they'd be wasting their time trying to explain complex things to people who don't know what they're doing. This is the 2D motion script that I've been using for a while. I'm not going to share the new version just yet.
{
// Motion
//motion(argument0 , argument1, argument2 , argument3) {
var_mode_01=argument0; // Mode: 1. Characters, 2. Bullets
var_object_01=argument1; // Object: Which ne is it. Based on ID Number
var_direction_01=argument2; // Direction: DUH!!!
var_speed_01=argument3; // Speed: More of the same
var_move_x=0; // X increment, added to the object's X value
var_move_y=0; // Y increment, added to the object's Y value
var_direction_01 = 11.25 * round(var_direction_01 / 11.25); // 11.25 * 36 = 360
// Keep the direction variable between 0 and 359
if(var_direction_01 > 360){ var_direction_01 = var_direction_01 - 360; }
if(var_direction_01 < 0){ var_direction_01 = var_direction_01 + 360; }
if(var_direction_01 == 360){ var_direction_01 = 0; }
// Showtime!
if(var_direction_01 == 135){ var_move_x = -1.00; var_move_y = -1.00; }
if(var_direction_01 == 123.75){ var_move_x = -0.75; var_move_y = -1.00; }
if(var_direction_01 == 112.5){ var_move_x = -0.50; var_move_y = -1.00; }
if(var_direction_01 == 101.25){ var_move_x = -0.25; var_move_y = -1.00; }
if(var_direction_01 == 90){ var_move_x = 0; var_move_y = -1.00; }
if(var_direction_01 == 78.75){ var_move_x = 0.25; var_move_y = -1.00; }
if(var_direction_01 == 67.5){ var_move_x = 0.50; var_move_y = -1.00; }
if(var_direction_01 == 56.25){ var_move_x = 0.75; var_move_y = -1.00; }
if(var_direction_01 == 45){ var_move_x = 1.00; var_move_y = -1.00; }
if(var_direction_01 == 33.75){ var_move_x = 1.00; var_move_y = -0.75; }
if(var_direction_01 == 22.5){ var_move_x = 1.00; var_move_y = -0.50; }
if(var_direction_01 == 11.25){ var_move_x = 1.00; var_move_y = -0.25; }
if(var_direction_01 == 0){ var_move_x = 1.00; var_move_y = 0; }
if(var_direction_01 == 348.75){ var_move_x = 1.00; var_move_y = 0.25; }
if(var_direction_01 == 337.5){ var_move_x = 1.00; var_move_y = 0.50; }
if(var_direction_01 == 326.25){ var_move_x = 1.00; var_move_y = 0.75; }
if(var_direction_01 == 315){ var_move_x = 1.00; var_move_y = 1.00; }
if(var_direction_01 == 303.75){ var_move_x = 0.75; var_move_y = 1.00; }
if(var_direction_01 == 292.5){ var_move_x = 0.50; var_move_y = 1.00; }
if(var_direction_01 == 281.25){ var_move_x = 0.25; var_move_y = 1.00; }
if(var_direction_01 == 270){ var_move_x = 0; var_move_y = 1.00; }
if(var_direction_01 == 258.75){ var_move_x = -0.25; var_move_y = 1.00; }
if(var_direction_01 == 247.5){ var_move_x = -0.50; var_move_y = 1.00; }
if(var_direction_01 == 236.25){ var_move_x = -0.75; var_move_y = 1.00; }
if(var_direction_01 == 225){ var_move_x = -1.00; var_move_y = 1.00; }
if(var_direction_01 == 213.75){ var_move_x = -1.00; var_move_y = 0.75; }
if(var_direction_01 == 202.5){ var_move_x = -1.00; var_move_y = 0.50; }
if(var_direction_01 == 191.25){ var_move_x = -1.00; var_move_y = 0.25; }
if(var_direction_01 == 180){ var_move_x = -1.00; var_move_y = 0; }
if(var_direction_01 == 168.75){ var_move_x = -1.00; var_move_y = -0.25; }
if(var_direction_01 == 157.5){ var_move_x = -1.00; var_move_y = -0.50; }
if(var_direction_01 == 146.25){ var_move_x = -1.00; var_move_y = -0.75; }
// Return the Results
// I made Arrays for the Player, the AI and the Bullets, so that I could
// have a single object that is responsible for multiple objects.
if(var_mode_01 == 1){
fps_comm_01.var_characters_01[var_object_01, 2] += (var_move_x * var_speed_01);
fps_comm_01.var_characters_01[var_object_01, 3] += (var_move_y * var_speed_01);
}
if(var_mode_01 == 2){
fps_comm_01.var_bullets_01[var_object_01, 5] += (var_move_x * var_speed_01);
fps_comm_01.var_bullets_01[var_object_01, 6] += (var_move_y * var_speed_01);
}
}
That is all!



This topic is locked







