1 registered members (AndrewAMD),
552
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How to confirm collision with level blocks?
[Re: Superku]
#444017
07/29/14 00:14
07/29/14 00:14
|
Joined: Jun 2014
Posts: 97 Lagos, Nigeria
tolu619
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
|
Using the AUM 4 snippets that Dlively posted, I've written this code
action RightMarkerAction()
{
set(my, PASSABLE);
my.blue = 100;
my.ambient = 100;
my.lightrange = 200;
while(1)
{
FrontRightPos.x = your.x + (50 * cos(your.pan)) + (50 * sin(your.pan));
FrontRightPos.y = your.y + (50 * sin(your.pan)) - (50 * cos(your.pan));
FrontRightPos.z = your.z;
vec_set(my.x,FrontRightPos);
wait(1);
}
}
action LeftMarkerAction()
{
set(my, PASSABLE);
my.red = 100;
my.ambient = 100;
my.lightrange = 200;
while(1)
{
FrontLeftPos.x = your.x + (50 * cos(your.pan)) - (50 * sin(your.pan));
FrontLeftPos.y = your.y + (50 * sin(your.pan)) + (50 * cos(your.pan));
FrontLeftPos.z = your.z;
vec_set(my.x,FrontLeftPos);
wait(1);
}
}
function CreateMarker()
{
FrontRightPos.x = my.x + (50 * cos(my.pan)) + (50 * sin(my.pan));
FrontRightPos.y = my.y + (50 * sin(my.pan)) - (50 * cos(my.pan));
FrontRightPos.z = my.z;
ent_create("box.mdl", FrontRightPos, RightMarkerAction);
FrontLeftPos.x = my.x + (50 * cos(my.pan)) - (50 * sin(my.pan));
FrontLeftPos.y = my.y + (50 * sin(my.pan)) + (50 * cos(my.pan));
FrontLeftPos.z = my.z;
ent_create("box.mdl", FrontLeftPos, LeftMarkerAction);
wait(1);
}
Now I have two transparent boxes floating slightly in front of my entity, 1 to the left and 1 to the right. They visually represent the vector positions that will check whether my entity has bumped into a wall. I don't know how exactly to perform that check. The AUM used C-SCript and the check was done using
BooleanVar = content(VectorToBeChecked);
if(BooleanVar == content_solid)
{ ObstcaleInThatDirection = 1;}
What's the lite-c equivalent of content() and content_solid?
|
|
|
Re: How to confirm collision with level blocks?
[Re: tolu619]
#444050
07/29/14 18:26
07/29/14 18:26
|
Joined: Jun 2014
Posts: 97 Lagos, Nigeria
tolu619
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
|
While waiting for a response, I found "in_solid", so I tried using it to detect whether my marker boxes were inside walls. When it didn't work, I copied and pasted the example from the manual and replaced my player's action code with it. I still don't get any response to show that it has detected a wall when my player touches one.
while(1)
{
c_move(me,vector(time_step*10,0,0), nullvector,0);
if (in_solid) // Is Entity inside a block?
{
error("Solid!");
}
if (in_passable) // Is Entity inside a passable block?
{
error("Passable!");
}
if (on_passable) // Is Entity on a passable block?
{
error("On water!");
}
wait(1);
}
|
|
|
Re: How to confirm collision with level blocks?
[Re: Superku]
#444071
07/30/14 00:35
07/30/14 00:35
|
Joined: Jun 2014
Posts: 97 Lagos, Nigeria
tolu619
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
|
I've bypassed the floating boxes now and I'm performing a trace directly from my player to the vectors where the boxes would have been located.
while(1)
{
.........
FrontRightPos.x = my.x + (50 * cos(my.pan)) + (50 * sin(my.pan));
FrontRightPos.y = my.y + (50 * sin(my.pan)) - (50 * cos(my.pan));
FrontRightPos.z = my.z;
FrontLeftPos.x = my.x + (50 * cos(my.pan)) - (50 * sin(my.pan));
FrontLeftPos.y = my.y + (50 * sin(my.pan)) + (50 * cos(my.pan));
FrontLeftPos.z = my.z;
if(c_trace(me, FrontRightPos, IGNORE_ME | IGNORE_MODELS | IGNORE_SPRITES | IGNORE_CONTENT)>0)
RightWall = 1;
if(c_trace(me, FrontLeftPos, IGNORE_ME | IGNORE_MODELS | IGNORE_SPRITES | IGNORE_CONTENT)>0)
LeftWall = 1;
if(RightWall == 1 && LeftWall == 1)
{
dash = 0; my.animation = 0; FrontWall = 1; WallRunning = 1;
printf("Front Wall!");
}
else if(LeftWall == 1 && RightWall == 0)
{
dash = 0; my.animation = 0; WallRunning = 1;
printf("Left Wall!");
}
else if(RightWall == 1 && LeftWall == 0)
{
dash = 0; my.animation = 0; WallRunning = 1;
printf("Right wall!");
}
.............
}
Both booleans "Leftwall" and "Rightwall" are set to 1 the moment I run the function that checks, regardless of how far away the player is from a wall. I tried using HIT_TARGET and got the same results.
c_trace(me, FrontRightPos, IGNORE_ME | IGNORE_MODELS | IGNORE_SPRITES | IGNORE_CONTENT);
if(HIT_TARGET)
{
RightWall = 1;
}
These first two options ALWAYS respond as if a wall was detected, even if it wasn't. If I use hit.nx to check, I'll never get a positive response, wall or not.
|
|
|
Re: How to confirm collision with level blocks?
[Re: DLively]
#444076
07/30/14 01:19
07/30/14 01:19
|
Joined: Jun 2014
Posts: 97 Lagos, Nigeria
tolu619
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
|
Try this:
result = c_trace(my.x, FrontRightPos.x, IGNORE_ME | IGNORE_MODELS | IGNORE_SPRITES | IGNORE_CONTENT);
if(result > 0)
{
RightWall = 1;
}
Didn't work. I've tried trace_hit, hit.texname (pretty much everything that follows the dot after 'hit'), I've been going through the manual and trying everything for 2 hours now. Everything I've tried either always gives a positive result or always gives a negative result, regardless of my actual position relative to a wall.
|
|
|
|