c_trace in certain direction

Posted By: Valdsator

c_trace in certain direction - 02/07/11 21:54

I looked through the manual and found out how to have something c_trace in the direction the entity is facing. For some reason though, when the entity does this, it immediately detects something with it's trace. But, when I put on IGNORE_WORLD, it doesn't detect it anymore.

Here's my code:
Code:
c_trace(my.x,vec_rotate(vector(5,0,0),my.pan),IGNORE_ME|IGNORE_YOU);


Is this doing something different? I assume it's setting a c_trace from the origin of the entity, to 5 units in the direction the entity is facing. What am I doing wrong?

Thanks in advance.
Posted By: Logan

Re: c_trace in certain direction - 02/07/11 22:14

Looks good... i.e. it should work. If IGNORE_WORLD makes it work, then the trace is obviously hitting a block or terrain right out of the gate. Maybe the model's origin is too low so it's hitting the floor every time? In which case start the trace from vector(my.x,my.y,my.z+100) for example instead of just my.x. That's just a guess, but it's gotta be a block or terrain, and it's gotta be close (within 5 quants). So there's only so many things it could be!

Try the floor thing... if that doesn't work, back to square one.
Posted By: Aku_Aku

Re: c_trace in certain direction - 02/07/11 22:39

Try to use this modifier: SCAN_TEXTURE
Perhaps you can get information about the objects what was hit.
From the manual:
Code:
if (hit.texname) printf("Floor texture: %s",hit.texname);


Posted By: Valdsator

Re: c_trace in certain direction - 02/08/11 00:10

Alright, using the texture name method, I found out it was hitting the floor of the level (the entity is a bullet, by the way). So I did what Logan said, but for some reason it still didn't work. I found it was still hitting the floor, so I then made the code this:
Code:
c_trace(vector(my.x,my.y,my.z),vec_rotate(vector(my.x+5,my.y,my.z),my.pan),IGNORE_ME|IGNORE_YOU);


This actually somewhat works. I guess the c_trace was coming from the origin of the entity, and just pointing at the floor. So I changed the 5,0,0 vector to that, and it then started working. But, now the c_trace seems a bit screwy. Sometimes the bullets don't activate the c_trace and slide along the wall, sometimes they make each other disappear, and sometimes they disappear before they should (too far away from the walls). I assume I changed the 5,0,0 to the wrong thing, so it's doing something very weird at the moment.

So since the c_trace was going from the entity down to the floor, what should I change the c_trace code to?
Posted By: Logan

Re: c_trace in certain direction - 02/08/11 00:31

By the way, I hate myself. I KNEW that using vector(5,0,0) was ALMOST there but not quite, as you have to add the entity's position to it as well, as you did. I just didn't catch it. Sorry about that. Good news is you solved the problem yourself, which is one of the best feelings in the world. So--you're welcome for letting you fix it on your own. wink

So I'm gathering that you are using this trace for a bullet to check if it is about to hit something. I don't know exactly why there are still problems, but my first question is why aren't you just using c_move and then performing special bullet-like behaviors when the bullet hits something (EVENT_BLOCK, EVENT_ENTITY, etc)?
Posted By: Logan

Re: c_trace in certain direction - 02/08/11 00:35

Also, you should add the MY entity's position after vec_rotate-ing. Actually, that might be a big source of problems.


c_trace(my.x,vec_add(vec_rotate(vector(5,0,0),my.pan),my.x),IGNORE_ME|IGNORE_YOU);
Posted By: Valdsator

Re: c_trace in certain direction - 02/08/11 02:27

Originally Posted By: Logan
c_trace(my.x,vec_add(vec_rotate(vector(5,0,0),my.pan),my.x),IGNORE_ME|IGNORE_YOU);

That didn't really seem to work for some reason, but I decided I'll try out the EVENT_BLOCK and EVENT_ENTITY way and it works perfectly. I guess I tried using c_trace because in the manual, on c_scan it says you shouldn't use c_scan for gunshots, but c_trace. It might be talking about bullets that don't travel, but just teleport. I might end up doing that, but for now this works. Thanks dude!
© 2024 lite-C Forums