Here's a free script on applying physics to a rope through c-script, no professional or commercial edition required, it just uses the laws of mathematics.
OOOOOOOOOOOCLICK HERE TO DOWNLOAD THE VERY SMALL ROPE PHYSICS DEMO!OOOOOOOOOO Here's a screenshot:
Here's the code for the whole demo:
Code:
////////////////////////////////////////////////////////////////////////
// A6 main wdl:
// Created by WED.
////////////////////////////////////////////////////////////////////////
path "Data";
/////////////////////////////////////////////////////////////////
// Filename of the starting level.
string rope_wmb = <ROPE.WMB>; // give file names in angular brackets
////////////////////////////////////////////////////////////////////////////
// Included files
include <gid01.wdl>; // global ids
include <display00.wdl>; // basic display settings
bind <burst.tga>;bind <axis.tga>;bind <temp.mdl>;bind <sphere.mdl>;
/////////////////////////////////////////////////////////////////
// Desc: The main() function is started at game start
function main()
{
// set some common flags and variables
// freeze all entity functions
freeze_mode = 1;
// no level has been loaded yet...
gid01_level_state = gid01_level_not_loaded;
// entry: Warning Level (0,1, or 2)
// entry_help: Sets sensitivity to warnings (0 = none, 1 = some, 2 = all).
warn_level = 2; // announce bad texture sizes and bad wdl code
// entry: Starting Mouse Mode (0, 1, or 2)
mouse_mode = 0;
// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);
// now load the level
level_load(rope_wmb);
wait(2); // let level load
// level should be loaded at this point...
gid01_level_state = gid01_level_loaded;
//+++ load starting values
freeze_mode = 0;
// main game loop
while(1)
{
if(gid01_level_state != gid01_level_loaded)
{
freeze_mode = 1; // pause the game
while(gid01_level_state != gid01_level_loaded) { wait(1); }
freeze_mode = 0; // resume the game
}
wait(1);
}
}
/////////////////////////////////////////////////////////////////
// The following definitions are for the pro edition window composer
// to define the start and exit window of the application.
WINDOW WINSTART
{
TITLE "3D GameStudio";
SIZE 480,320;
MODE IMAGE; //STANDARD;
BG_COLOR RGB(240,240,240);
FRAME FTYP1,0,0,480,320;
// BUTTON BUTTON_START,SYS_DEFAULT,"Start",400,288,72,24;
BUTTON BUTTON_QUIT,SYS_DEFAULT,"Abort",400,288,72,24;
TEXT_STDOUT "Arial",RGB(0,0,0),10,10,460,280;
}
/* no exit window at all..
WINDOW WINEND
{
TITLE "Finished";
SIZE 540,320;
MODE STANDARD;
BG_COLOR RGB(0,0,0);
TEXT_STDOUT "",RGB(255,40,40),10,20,520,270;
SET FONT "",RGB(0,255,255);
TEXT "Any key to exit",10,270;
}*/
/////////////////////////////////////////////////////////////////
//INCLUDE <debug.wdl>;
var tester=0;bmap axis=<axis.tga>;bmap burst = <burst.tga>;
entity* rope0;entity* rope1;entity* rope2;entity* rope3;entity* rope4;entity* rope5;
font standard_font = <font1020.bmp>,10,20;var gravity=9;var spacing=40;
string gravi="space to morph objects\nright click for camera rotation\nmouse wheel to zoom\nleft/right arrows for spacing\nleftclick for up/down movement\n\n\n\n\n\n\n\n\nGRAVITY (M/S)\n(up/down arrow\nto change)";
text grav{pos_x=10;pos_y=0;font=standard_font;string=gravi;flags=visible;}
panel debugger{pos_x=0;pos_y=0;flags=visible;
digits=50,320,4,standard_font,-1,gravity;
digits=70,480,4,standard_font,1,rope0.x;
digits=70,500,4,standard_font,1,rope0.y;}
panel debugger2{pos_x=0;pos_y=0;flags=visible;bmap = burst;}
panel debugger3{pos_x=0;pos_y=400;flags=visible;bmap = axis;}
//for multiple of the same
function roper1(){rope0.skill1-=spacing;my.light=on;my.ambient=-100;
if(rope0.skill1>-3000){ent_create("temp.mdl",vector(0,0,rope0.skill1),roper1);}
my.pan=my.z/10;
while(1){
if(rope0.skill50!=my.skill50){if(rope0.skill50==1){ent_morph(my,"sphere.mdl");
my.skill50=rope0.skill50;}else{ent_morph(my,"temp.mdl");my.skill50=rope0.skill50;}}
my.pan+=10*time;
my.red=126*cos(my.z-total_ticks*7)+126;my.green=126*cos(my.z-120-total_ticks*7)+126;
my.blue=126*cos(my.z-240-total_ticks*7)+126;
vec_diff(my.skill1,my.x,you.x);vec_to_angle(my.skill4,my.skill1);//find the angle between the object closer to the rope end and this one
if(my.skill5>-90+gravity/1.5){my.skill5-=5*gravity*time;}vec_for_angle(my.skill1,my.skill4);//allow gravitational change of object
//depending on object closer to rope end by decreasing its euler tilt in
//relationship to the higher object
vec_normalize(my.skill1,spacing);vec_add(my.skill1,you.x);vec_set(my.x,my.skill1);//keep the object the same distance
//away from the next object closer to the rope end to prevent stretch of rope
//because of movement
wait(1);}
}
action roper{my.passable=on;rope0=me;
ent_create("temp.mdl",vector(0,0,my.skill1),roper1);wait(30);
while(1){
if(mouse_left==off){
my.x+=mickey.x*2;my.y-=mickey.y*2;}else{
my.x+=mickey.x*3;my.z-=mickey.y*3;}
//my.x=clamp(my.x,-400,400);my.y=clamp(my.y,-400,400);
if(my.x>=-400 && my.x<=400){debugger2.pos_x=my.x/5+100-(16);}
if(my.y>=-400 && my.y<=400){debugger2.pos_y=-my.y/5+500-(16);}
if(key_cuu==on){gravity+=time;}if(key_cud==on){gravity-=time;}
if(key_cur==on){spacing+=3*time;}if(key_cul==on){spacing-=3*time;}
spacing=clamp(spacing,10,5000000);//set spacing to 1 for springiness!
wait(1);}}
function morfob(){if(rope0.skill50==1){rope0.skill50=0;
ent_morph(rope0,"temp.mdl");}else{rope0.skill50=1;ent_morph(rope0,"sphere.mdl");}}
on_space=morfob;
action light{my.invisible=on;my.passable=on;my.lightrange=2000;
my.skill2=30;my.skill1=-97;
my.skill7=900;//zoom
while(1){
my.red=126+126*cos(total_ticks*5);my.green=126+126*cos(total_ticks*5-120);
my.blue=126+126*cos(total_ticks*5-240);
my.skill7-=mickey.z/2;
if(mouse_right==on){my.skill1+=mickey.x/3;my.skill2-=mickey.y/3;
my.skill2=clamp(my.skill2,-89,89);}
vec_for_angle(my.skill4,my.skill1);vec_normalize(my.skill4,my.skill7);
vec_set(camera.x,my.skill4);vec_set(my.skill4,camera.x);
vec_inverse(my.skill4);vec_to_angle(camera.pan,my.skill4);
wait(1);}
}
Have fun!
Look forward to cloth and paper examples coming soon!