2 registered members (AndrewAMD, VoroneTZ),
779
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
c_trace problem
#399792
04/20/12 08:56
04/20/12 08:56
|
Joined: Oct 2005
Posts: 57
picoder
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2005
Posts: 57
|
If I change position of a model immediately before tracing, c_trace checks this model according to previous position. I changed small.c in samples folder for test:
function main()
{
level_load("small.hmp");
vec_set(camera.x,nullvector);
vec_set(camera.pan,nullvector);
ENTITY* target_ent = ent_create("earth.mdl", vector(0,0,1000), NULL);
wait(-2);
vec_set(target_ent.x,vector(100,0,0));
//if target position bigger than 982, it works.
c_trace(camera.x,vector(982,0,0),IGNORE_PASSABLE);
if (HIT_TARGET)
{
if(you==target_ent){beep();}
}
}
|
|
|
Re: c_trace problem
[Re: Superku]
#399801
04/20/12 11:39
04/20/12 11:39
|
Joined: Oct 2005
Posts: 57
picoder
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2005
Posts: 57
|
You can immediately update collision hull (without polygon flag) by model position. I didn't use c_move in test code but If I increase trace distance, c_trace can hit the target.
c_trace(camera.x,vector(990,0,0),IGNORE_PASSABLE);
If I need wait until the end of the frame, how does trace hit the target in the above code?
|
|
|
Re: c_trace problem
[Re: picoder]
#399802
04/20/12 11:53
04/20/12 11:53
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
You can immediately update collision hull (without polygon flag) by model position. How do I do that? EDIT: This should prove all my points:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
void main()
{
fps_max = 60;
level_load(NULL);
player = ent_create(CUBE_MDL,vector(100,50,0),NULL);
while(1)
{
if(key_space) c_move(player,nullvector,vector(0,-100,0),IGNORE_PASSABLE | IGNORE_WORLD | IGNORE_MODELS);
else player.y = -50;
c_trace(vector(0,-50,0),vector(200,-50,0),IGNORE_PASSABLE | USE_POLYGON);
if(trace_hit) beep();
if(key_space) c_move(player,nullvector,vector(0,100,0),IGNORE_PASSABLE | IGNORE_WORLD | IGNORE_MODELS);
else player.y = 50;
wait(1);
}
}
Last edited by Superku; 04/20/12 12:02.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: c_trace problem
[Re: Superku]
#399803
04/20/12 12:07
04/20/12 12:07
|
Joined: Oct 2005
Posts: 57
picoder
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2005
Posts: 57
|
You don't need anything. Please test my sample code.
function main()
{
level_load("small.hmp");
vec_set(camera.x,nullvector);
vec_set(camera.pan,nullvector);
ENTITY* target_ent = ent_create("earth.mdl", vector(0,0,1000), NULL);
wait(-2);
vec_set(target_ent.x,vector(100,0,0));
//if target position bigger than 982, it works.
c_trace(camera.x,vector(990,0,0),IGNORE_PASSABLE);
if (HIT_TARGET)
{
if(you==target_ent){beep();}
}
}
Edit: If POLYGON flag of your target model is set or there is USE_POLYGON flag in c_trace, you're right. But my problem is different, it's about non-polygonal models.
Last edited by picoder; 04/20/12 12:19.
|
|
|
Re: c_trace problem
[Re: jcl]
#399815
04/20/12 14:42
04/20/12 14:42
|
Joined: Oct 2005
Posts: 57
picoder
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2005
Posts: 57
|
This is not a bug - use c_updatehull when you need to update the collision hull. If I need use c_updatehull, how does trace hit the target in below code? (without c_updatehull or c_move)
function main()
{
level_load("small.hmp");
vec_set(camera.x,nullvector);
vec_set(camera.pan,nullvector);
ENTITY* target_ent = ent_create("earth.mdl", vector(0,0,1000), NULL);
wait(-2);
vec_set(target_ent.x,vector(100,0,0));
//if target position bigger than 982, it works.
c_trace(camera.x,vector(990,0,0),IGNORE_PASSABLE);
if (HIT_TARGET)
{
if(you==target_ent){beep();}
}
}
|
|
|
|