Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, juanex, Grant), 1,018 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
triggering a model to start a path #69380
04/02/06 02:21
04/02/06 02:21
Joined: Nov 2005
Posts: 49
Massachusetts
T
TBone Offline OP
Newbie
TBone  Offline OP
Newbie
T

Joined: Nov 2005
Posts: 49
Massachusetts
Hello,

I'm having some trouble getting this code to work.
What I'm trying to do:
I'm trying to get a model to follow a path after another model colides with it's trigger. There are 3 models together, the player model, the ball model, and an invisible box I'm using as a trigger to start the ball on its path. I'm using a trigger so I can control which side of the ball the player has to be.

here is the code:
Code:
  action Ball_path
{
counter = 0; // there are 23-24 waypoints in path
temp.pan = 360; // scanning radius horizontal
temp.tilt = 180;// scanning radius vertical
temp.z = 1000; // scanning distance
result = scan_path (my.x, temp); scanning for path

if (result == 0) //if the scan finds no paths
{
return;
}

ent_waypoint(my._TARGET_X,1); //1st waypoint found

while (counter<24)//counts the number of waypoints
{
temp.x = my._TARGET_X - my.x; //distance to next waypoint
temp.y = 0;
temp.z = my._TARGET_Z - my.z;
result = vec_to_angle(my_angle,temp);

if (result < 100) // if point found within distance
{
ent_nextpoint (my._TARGET_X);
counter+=1;
}
//move the ball on the path
c_move(my, vector(temp.x, 0, temp.z), nullvector,ignore_passable);

wait(1);
}

score_basket();


}


function Ball_Path_linker()
{ //if impact between trigger and player and the mouse button is pressed
if( (event_type == event_impact)&&(mouse_left==1) )
{
beep(); //test
ball_path(); //call function for ball to follow path
}
}

action Trigger_Ball_path
{ //model set for impact event
my.enable_impact=on;

my.event= ball_path_linker;

}




summary of code operation (or expected operation):
action Trigger_ball_path is attached to the trigger in WED
action ball_path is attached to the ball
function ball_path_linker is called when an impact between the player and trigger occur.

Does anyone see why this doesn't work.

I'm trying to trigger an action after an impact, but trying to control what side of the model the impact occurs.
Thanks


"Supreme executive power derives from a mandate of the masses NOT some farcicle aquatic ceromony" Constitutional peasant skit "Monty Python and the Holy Grail"
Re: triggering a model to start a path [Re: TBone] #69381
04/02/06 11:23
04/02/06 11:23
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Add the event event_entity
To your Trigger_Ball_path and the event function:
Code:

function Ball_Path_linker()
{ //if impact between trigger and player and the mouse button is pressed
if( (event_type == event_impact || event_type == event_entity)&&(mouse_left==1) )
{
beep(); //test
ball_path(); //call function for ball to follow path
}
}

action Trigger_Ball_path
{ //model set for impact event
my.enable_impact = on;
my.enable_entity = on;
my.event = ball_path_linker;
}



Re: triggering a model to start a path [Re: Xarthor] #69382
04/02/06 12:59
04/02/06 12:59
Joined: Nov 2005
Posts: 49
Massachusetts
T
TBone Offline OP
Newbie
TBone  Offline OP
Newbie
T

Joined: Nov 2005
Posts: 49
Massachusetts

Thanks for the code.
I tried incorporating this into my code and it's still not working.

In WED the Trigger_ball_path is the action attached to the invisible box model I'm using for the trigger.

The player who colides with the trigger has the following code:
He moves on his own in one direction and the camera follows him.This code works pretty good but I think it is trigger the "Trigger_Ball_path action prematurely.

Code:
 
action b_ball_Player_move
{
var temporaryValue=0;

while(me)
{

//animate walk image sequence
ent_animate(my,walk_animate,walk_percent,anm_cycle );
walk_percent += 2* time;

// move forward
c_move(my,vector(3,0,0), nullvector, activate_trigger);

//Call function to allow camera view to follow the player around
move_view_3rd_2(); //note: changed variable in function from 16 to 1

// if left mouse button pressed turn left
if(mouse_left == 1)
{
temporaryValue.pan = 3;// pan or turn left, if it were -=1 then he would turn right
c_rotate (my, temporaryValue, activate_trigger);

//move in new direction
c_move(my,vector(0,0,0), nullvector,activate_trigger);

//clear mouse button setting
mouse_left =0;

}

wait(1);

}

}




your corrections incorporated into my code:

Code:
 
//////////////////////////////
// Event and action to throw ball into net
//////////////////////////////
var counter =0;
function Ball_path()
{
// scanning for path
counter = 0; //number of waypoints
temp.pan = 360;
temp.tilt = 180;
temp.z = 1000;
result = scan_path (my.x, temp);

if (result == 0)
{
return;
}

ent_waypoint(my._TARGET_X,1);

//loop for ball to travel path
while (counter<24)
{
temp.x = my._TARGET_X - my.x;
temp.y = 0;
temp.z = my._TARGET_Z - my.z;
result = vec_to_angle(my_angle,temp);

if (result < 23)
{
ent_nextpoint (my._TARGET_X);
counter+=1;
}
//move ball model along path
c_move(my, vector(temp.x,0,temp.z), nullvector,ignore_passable);

wait(2);
}
score_basket();

}

function Ball_Path_linker()
{
//if impact between trigger and player and the mouse button is pressed
if( (event_type == event_impact || event_type == event_entity)&&(mouse_left==1) )
{
beep(); //test
ball_path(); //call function for ball to follow path
}
}

action Trigger_Ball_path
{ //model set for impact event
my.enable_impact = on;
my.enable_entity = on;
my.event = ball_path_linker;
}



I tried using break points on the last line in the Trigger_Ball_path (line my.event = ball_path_linker;). The breakpoint stopped here but was triggered at the very start of the game. I think the activate_trigger mode ,in the cmove()calls from the b_ball_player_move, tripped this. I set a breakpoint at the functions and neither were called.

any other ideas to help.
Thanks


"Supreme executive power derives from a mandate of the masses NOT some farcicle aquatic ceromony" Constitutional peasant skit "Monty Python and the Holy Grail"
Re: triggering a model to start a path [Re: TBone] #69383
04/02/06 14:16
04/02/06 14:16
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Ah I got another idea for ya,
why not use vec_dist + mouse_left:
add:
player = me;
in your player's action (at the very top of it)
Code:

var counter = 0;

action ball_path
{
while(!player) { wait(1); } //wait until the player is created
my.skill2 = 0;
while(!my.skill2)
{
if((vec_dist(my.x,player.x) < 50) && mouse_left == 1)
{ my.skill2 = 1; )
wait(1);
}

counter = 0; //number of waypoints
temp.pan = 360;
temp.tilt = 180;
temp.z = 1000;
result = scan_path (my.x, temp);

if (result == 0)
{
return;
}

ent_waypoint(my._TARGET_X,1);

//loop for ball to travel path
while (counter<24)
{
temp.x = my._TARGET_X - my.x;
temp.y = 0;
temp.z = my._TARGET_Z - my.z;
result = vec_to_angle(my_angle,temp);

if (result < 23)
{
ent_nextpoint (my._TARGET_X);
counter+=1;
}
//move ball model along path
c_move(my, vector(temp.x,0,temp.z), nullvector,ignore_passable);

wait(2);
}
score_basket();
}



Last edited by Thunder; 04/02/06 14:18.
Re: triggering a model to start a path [Re: Xarthor] #69384
04/03/06 16:48
04/03/06 16:48
Joined: Nov 2005
Posts: 49
Massachusetts
T
TBone Offline OP
Newbie
TBone  Offline OP
Newbie
T

Joined: Nov 2005
Posts: 49
Massachusetts
the triggering doesn't seem to work. I'm running out of time so I'll just use the ball as a trigger.

thanks for the help though it is greatly appreciated.


"Supreme executive power derives from a mandate of the masses NOT some farcicle aquatic ceromony" Constitutional peasant skit "Monty Python and the Holy Grail"

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