Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, ozgur, AbrahamR, wdlmaster), 849 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pushable box question #178831
01/19/08 20:02
01/19/08 20:02
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline OP
Serious User
JetpackMonkey  Offline OP
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco
Hi, I'm using the following script, but when my character pushes the box, it skitters and stutters unpleasantly. Any ideas how to make this slide more smoothly?

Code:
  action pushable_box

{

while (player == null) {wait (1);}

var my_angle;

while (1)

{

// play with 50 - it depends on the size of the box

if (vec_dist (player.x, my.x) < 50)

{

vec_set(temp.x, player.x);

vec_sub(temp.x, my.x);

vec_to_angle(my_angle.pan, temp.x);

temp.x = -10 * cos(my_angle.pan - my.pan) * time;

temp.y = -10 * sin(my_angle.pan - my.pan) * time;

temp.z = -1 * time;

c_move (my, temp.x, nullvector, ignore_you | ignore_passable | glide);

}

wait (1);

}

}



Re: Pushable box question [Re: JetpackMonkey] #178832
01/20/08 09:59
01/20/08 09:59
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline
User
badapple  Offline
User

Joined: Apr 2006
Posts: 624
DEEP 13
try this,


action pushable_box
{
my.enable_impact=on;
my.event=push_box;
}

function push_box()
{my.event=null;
var box_movement;
while (vec_dist (player.x, my.x) < 200)
{
if (vec_dist (player.x, my.x) < 50)
{
box_movement.x = 10 * cos(player.pan) * time;
box_movement.y = 10 * sin(player.pan) * time;
vec_set (temp, my.x);
temp.z -= 2000;
trace_mode = ignore_me +ignore_passable + use_box;
box_movement.z = -trace(my.x, temp);
move_mode = IGNORE_ME +IGNORE_YOU +ignore_passable+ GLIDE;
ent_move(box_movement, nullvector);
//c_move (my, box_movement, nullvector, ignore_you | ignore_passable | glide);
}
wait (1);
}

my.event=push_box;
}

i added a function to push the box so that your box action does not need a while
loop running constantly eating up valuable memory , i tested this with ent_move
instead of c_move but im sure it will work just as well with c_move just get
rid of my move_mode and ent move lines and uncomment c_move again if c_move is
what you want, but like i said i tested it and i think its much smoother and less jittery

cheers



and yes kasimir is right proc_kill(4) definitly smart to do or null box event
on impact and restore at end of while loop to ensure only one instance of this
function is running

Last edited by badapple; 01/20/08 12:52.
Re: Pushable box question [Re: badapple] #178833
01/20/08 10:18
01/20/08 10:18
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
sry but your code is not perfect too - you need to add this:

Code:

function push_box()
{
proc_kill(4);
...


i think if you touch the box the function is called several times... so with proc_kill all other function will be eliminated! -> this saves also memory

Last edited by kasimir; 01/20/08 10:21.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1