line from player to nearest ground
Moderator: Moderators
line from player to nearest ground
what's the code for if a line (or func_beam) touches the ground?
i need a line from the player (NOT binocs) to the nearest brush/patch/LOD. i jsut dont know the code for detecting brushes with lines.
i need a line from the player (NOT binocs) to the nearest brush/patch/LOD. i jsut dont know the code for detecting brushes with lines.
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
local.fwd_vec = angles_toforward local.player.viewangles
local.start = local.player gettagposition "Bip01 Head"
local.range = 10240
local.groundtarget.origin = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
like that you mean ? it does a trace and gives you the spot where the trace hits something . No line though at least not one you can see .
local.start = local.player gettagposition "Bip01 Head"
local.range = 10240
local.groundtarget.origin = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
like that you mean ? it does a trace and gives you the spot where the trace hits something . No line though at least not one you can see .
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
Bdbodger, your code does a trace from player's head to where's the player looking at, and I don't think that's what he asked for.
You can trace the func_beam endpoint that would go straight down to the ground like this:
You can trace the func_beam endpoint that would go straight down to the ground like this:
Code: Select all
local.endpoint = trace local.player.origin (local.player.origin + ( 0 0 -16384 ))exactly what i need. if it draws a trace to the nearest solid and get the position of the spot it hit the solid, it's what i want. from what i see of it that's what it does.like that you mean ? it does a trace and gives you the spot where the trace hits something . No line though at least not one you can see .
thanks BD!
that's useful as well, just showed me how to offset a trace downwards too, which was going to be my next questionBdbodger, your code does a trace from player's head to where's the player looking at, and I don't think that's what he asked for.
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
Well anyway it does a trace from point A to point B and the result is the spot it hit if it hit anything at all . The 0 at the end tell it to not pass entites
trace( Vector start, Vector end, [ Integer pass_entities ], [ Vector mins ], [ Vector maxs ] )
Performs a Trace Line from the start to the end, returns the end or the position it hit at
not sure what the Vector mins or Vector maxs are used for
trace( Vector start, Vector end, [ Integer pass_entities ], [ Vector mins ], [ Vector maxs ] )
Performs a Trace Line from the start to the end, returns the end or the position it hit at
not sure what the Vector mins or Vector maxs are used for
bad news, i just tried it after getting errors and deciding to skip them and work on other things, i just got back to it and apparently, the trace isn't getting anything at all.

the iprintln always returns NIL... i tried it with .origin and without it. apparently the trace isn't workinglocal.fwd_vec = angles_toforward local.player.viewangles
local.start = local.player gettagposition "Bip01 Head"
local.range = 10240
local.groundtarget.origin = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
iprintln "origin is " local.groundtarget.origin " ... "
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
Yes local.groundtarget was a script_origin from my player spotlight script . Any time you use local.something.origin it has to be something to have an origin or for you to give it an origin dosen't it ! , if you take out the origin part it should give you a set of coords but then you have to make sure the coords do not match the endpoint because that means it did not hit anything .local.groundtarget.origin = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
if you do that then local.ground will be the coords it hit at or didn't hit at as the case maybe . If you use a very far endpoint it should hit something I guess .local.ground = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
Code: Select all
local.fwd_vec = angles_toforward local.player.viewangles
local.start = local.player gettagposition "Bip01 Head"
local.range = 10240
local.ground = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
iprintln "origin is " local.ground " ... "
level.Private1 runto local.ground
level.Private2 runto local.ground
level.Private3 runto local.ground
level.Medic runto local.ground
level.Sergeant runto local.ground
level.Heavy runto local.ground
level.Captain runto local.groundHELP!
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
Try putting some iprintln statements in there to see what is working . Did you define what local.player was ? If you are testing it alone try $player instead of local.player . If local.player and local.start are defined then there is no way that local.ground would display nil it would display coords .
local.fwd_vec = angles_toforward local.player.viewangles
iprintln local.fwd_vec
local.start = local.player gettagposition "Bip01 Head"
iprintln local.start
local.range = 10240
local.ground = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
iprintln "origin is " local.ground " ... "
local.fwd_vec = angles_toforward local.player.viewangles
iprintln local.fwd_vec
local.start = local.player gettagposition "Bip01 Head"
iprintln local.start
local.range = 10240
local.ground = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
iprintln "origin is " local.ground " ... "
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
YES! that was it! i hadn't defined local.player as $player!
*dissolves into happy sobbing*

but it's good experience.
ok now... you said it does entities too right? how can i tell what kind of entity it hits if it does? some kind of command,
*dissolves into happy sobbing*
heh yeah... slowly making my way through itI see you're still working on that bot command mod, eh?
but it's good experience.
ok now... you said it does entities too right? how can i tell what kind of entity it hits if it does? some kind of command,
Code: Select all
if(isEntity local.ground)
{
local.entity = parm.other
iprintln "You hit an entity!"
if(local.entity.classname == func_door || local.entity.classname == func_rotatingdoor)
{
// do something cool :)
}
}Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
Ah, sorry, I was wrong. Actors apparently can runto vectors.
As to your question, no. Local.ground is a variable of type vector, not entity.
There is no perfect way to determine if a thing on certain coords is or is not an entity, but if you really want it, you could perform a double trace - one with the pass_entities flag set to 1, and one with it set to 0.
Apparently, this method is not perfect because the entities have different heights and you cannot determine the exact position of the entity.
As to your question, no. Local.ground is a variable of type vector, not entity.
There is no perfect way to determine if a thing on certain coords is or is not an entity, but if you really want it, you could perform a double trace - one with the pass_entities flag set to 1, and one with it set to 0.
Code: Select all
// let's assume local.ground is the spot
local.check_w_ents = trace (local.ground + ( 0 0 64 )) (local.ground + ( 0 0 -8 )) 0 // the last 0 is the pass_entities flag
local.check_wo_ents = trace (local.ground + ( 0 0 64 )) (local.ground + ( 0 0 -8 )) 1
if (local.check_w_ents != local.check_wo_ents)
println "There's an entity between " local.check_w_ents " and " local.check_wo_ents "!"


