Tracing to the top of the map?

I know this is a simple script… But I haven’t ever seen this done (but I know its fairly easy, I just havent seen anyone do it) so I don’t know how to do it myself. But is what I am trying to do is make a trace to find the top of the map and subtract 250 units from it. Pl0xandTy

It has been done a lot for weather scripts like on this thread: check for a post by Overv where he traces from a players position to the skybox.

if( trace.HitSky ) then
// do something

I appreciate the attempt, but that returns a Boolean, not a vector, which is what I need.

You can use trace.HitPos to get the position of where a trace hits an object.

Why don’t you use the wiki:

You wanted to know how to trace to the skybox so I answered. I don’t spoon feed people sorry because then they don’t learn how to figure stuff out for themselves ever.

God… I already knew about trace.HitPos I am asking how to trace UP! Its a really simple question.

Simple questions don’t always have simple answers. Do you want it to always trace up? Or only when a player looks?

Its just a one time thing. I’m trying to trace from the players position to the top of the map and subtract 250 from Z. Emz is apparently not able to read today because usually he is very helpfull. He just didn’t read the OP lol

local tr

tr = { }
tr.start = wherever
tr.endpos = tr.start + Vector( 0, 0, height )
tr.filter = whatever

tr = util.TraceLine( tr )

if tr.HitSky then
–We are under the sky

		local trace = { }
		trace.start = pl:GetPos()
		trace.endpos = trace.start + Vector(0,0,1000000)
		trace.filter = MASK_ALL
		local tr = util.TraceLine(trace)
		SpawnPos = tr.HitPos
		SpawnPos.z = SpawnPos.z - 250

Didn’t quite work XD

Filter is an entity or table of entities.

tr.filter = pl

Crap. So how would I stop at the world? I need to get the Z value of the top of the map.

It will hit the first object that matches the mask option ( defaults, I think, to MASK_ALL ). If you want it to ignore brushes, well, there’s probably a mask for that.

Maybe MASK_NPCSOLID_BRUSHONLY? It is listed as only hitting the world and will ignore any entities.

Well I dont think its hitting anything with MASK_ALL because when I spawn I’m surrounded by blackness >.>

You sir, are an idiot.

If you’d read the first link I gave you, it would have said how to do what you wanted (how to “trace upwards lol.”)

I’m sorry to be frank, but you’re the most ungrateful person I have seen for a while.

Plus, I am a “she” thanks. And I read fine. You first asked how to trace to the skybox and I said how to detect if a trace hits the skybox. You then said you wanted a vector at the collision, so I said how to do that. I am sorry that I’d rather you figure out some of the steps yourself instead of spoonfeeding you. My method of teaching is to direct not to give out the answer.

I use to spoonfeed but people never learnt from it.

You Ma’am (???) are STILL not reading. Heres my first post. where the HELL do i mention anything about the skybox? I do not see the word “Skybox” in my original post anywhere! You have told me trace.HitPos which I already knew. I’ve worked with traces before and I know how to use them. I simply do not know how to point them UP! You’ve attempted to give me help, which I have thanked you on, but what you have given me is:
trace.HitPos - Knew it already
Util.TraceLine On the Wiki - Either this is what you mean by giving me the info? Yet it is unclear on how to poin UP in the freaking wiki.
trace.HitSky - this is a BOOLEAN! not a vector

SO! Emz, you STILL have not anwsered my damned question and you can look at the code I posted in response to Kogitsunes CORRECT attempt to help me. He is on the right track I just dont know how to stop the trace at the top. Now, Either READ my posts or kindly leave. I would appreciate your help in a later date or different topic, but as of now you are not helping AT ALL.

And giving me a oneliner is not spoon-feeding me… so get that crap out of your head. I am very experianced with LUA and if you dont help anyone then they CANT learn, if you think about that for a minuet.

She is trying to help. Stop moaning.

Title: Tracing to the top of the map?

It is quite clear you are wanting to get the distance to the skybox. If you don’t want our help, get the fuck out. We arn’t a bunch of people who you can walk all over and then automatically expect us to help you. Emz had the decency to try, and you disregarded what she quite correctly said.

If you don’t want help, don’t bother posting in here.

If you were, you would realise she pointed you to exactly what you wanted and you would know how to use the wiki.

@Jamie: I know that and I thanked her for her efforts, but she is flaming me because she has not been able to give me an anwser.

@Flapjack: NO SHIT SHERLOCK! its a simple fucking question that NONE of you know how to anwser! I want the DISTANCE. Emz is giving me random checks about if its hiting the skybox. it has NOTHING to do with vectors or distances. Both of yall have reading disorders or some shit that is preventing you from using your brains!

I will put it in the DUMBEST way so that even a 2 year old will be able to figure this out. Because none of you are getting what I am asking for. Kogitisune knows, but He hasnt responded again.

Now. My final kind attempt at asking this:
If I am in flatgrass, I want to spawn 250 units from the top of the map. How would I trace from the players position (aka trace.start) to the top of the map (AKA trace.end [which is where I need help aiming UP]) and then getting the HitPos of that trace. Then i want to set the players position to the HitPos and subtract 250 units from HitPos.z so that the Player will spawn near the top of the map.

Distance(trace.HitPos , LocalPlayer():GetPos())



So yes, it does involve the trace.

Then just use SetPos to change where the player is. You could just do player:SetPos(trace.HitPos - Vector(0 , 0 , 25))

THANK YOU! That is what I needed. Don’t get how, but it works. Thank you!