Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (AndrewAMD), 1,310 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Difficulty with c_trace. #250122
02/06/09 00:50
02/06/09 00:50
Joined: Aug 2006
Posts: 70
NJ
S
SirCamaris Offline OP
Junior Member
SirCamaris  Offline OP
Junior Member
S

Joined: Aug 2006
Posts: 70
NJ
I'm not sure why I can't get c_trace to work. I downloaded the workshop that came along with AUM51 and it ran fine. I tried to adapt the code to my own script many different ways but none of them work. The idea is to make the player move when the space key is pressed, but by first activating c_trace to look for wall entities. When c_trace detects a wall entity, the player should move, but doesn't. The move_forward() function works fine and requires a single key to be pressed as well, but doesn't use c_trace. I've defined the wall entity, placed it in an action and attached the action to the wall entity in WED, just like in workshop 26. The wall entity that I speak of is really a hollowed out box, with which the player can pass through. The player is a sprite but I'm not sure where the c_trace origin is coming from. I would appreciate any help that you can give. If any part of my problem is unclear and needs refinement, please let me know. Thank you.

ENTITY* Walls_ent; //WALL ENTITY


function move_forward() //THIS FUNCTION WORKS FINE AND IS CALLED IN THE PLAYER_MOVE ACTION
{ var new_position = 256;
var old_position = 0;
while (old_position < new_position)
{c_move (my, vector(64, 0, 0), nullvector, GLIDE);
old_position += 64;
wait(1);
}
}

action Walls_act() //THIS ACTION IS ATTACHED TO ALL WALL ENTITIES IN LEVEL
{ Walls_ent = my;
}

function wall() //THIS FUNCTION DOESN'T WORK AND IS CALLED IN THE PLAYER_MOVE ACTION
{ while(1)
{ c_trace (player.x, Walls_ent.x, IGNORE_ME + USE_BOX); // trace from the weapon to the enemy
if (you == Walls_ent) // got the enemy?
{ c_move(player, vector(64,0,0), nullvector, GLIDE);
}
wait(1);
}
}

action player_move()
{ player = my;
while (1)
{camera_view.pan = player.pan;
camera_view.x = player.x;
camera_view.y = player.y;

if (key_w - key_d - key_s - key_a == 1) //only key_w is being pressed
{ while (key_w - key_d - key_s - key_a == 1) //while key_d is being held, wait a frame
{wait(1);}
move_forward();
}

if (key_space == 1) // only key_space is being pressed
{ while (key_space == 1) // while key_space is being held, wait a frame
{wait (1);}
wall();
}
wait (1);
}
}

Re: Difficulty with c_trace. [Re: SirCamaris] #250126
02/06/09 01:03
02/06/09 01:03
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
PlaystationThree Offline
Junior Member
PlaystationThree  Offline
Junior Member

Joined: Jul 2008
Posts: 54
Taipei, Taiwan
I think it's because the wall() action makes the Walls_ent entity to the particular wall that's running the script. Well each time a new wall is set to be Walls_ent, it replaces the previous Wall_ent. It's like a variable, it can only be wall_1, wall_2, wall_3, wall_4 or wall_5, not all of them at the same time.
As a solution, try putting all your walls into one single mesh, and in WED set the POLYGON flag on it and give it the wall() action. Remember the Walls_ent can only be a single entity at any given time, so the wall() action should be set on only one entity.


Bet you don't know where Taiwan is lol.

"The Lord is my light and my salvation..." Psm 27:1
Re: Difficulty with c_trace. [Re: PlaystationThree] #250136
02/06/09 04:44
02/06/09 04:44
Joined: Aug 2006
Posts: 70
NJ
S
SirCamaris Offline OP
Junior Member
SirCamaris  Offline OP
Junior Member
S

Joined: Aug 2006
Posts: 70
NJ
Thank you PS3; some progress has been made. I grouped all of the wall entities together and checked the polygon box. Now when I press key_space, the player keeps moving until it hits a wall, which means c_trace is working. I'm not sure why the function runs only once per program execution, but this is something I will play with. Thanks again for your input.


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