Page 1 of 2
Pathfinding / Beams through walls?
Posted: Sat Apr 29, 2006 2:11 pm
by Rookie One.pl
Has anyone been able to make func_beams appear through walls? Alwaysdraw doesn't work, it seems a trace is being done at the moment of activating the beam from origin to endpoint, and it stops at any solid found on the way. I tried tracing forward from inside the solid (endpoint + forward vector - this is 1 unit deep inside the wall), but the game refuses to do so and traces from the surface (where the beam endpoint is), which is useless, and as a result I get an error (either all edicts have been used or a command overflow). Any ideas?
Posted: Sat Apr 29, 2006 3:07 pm
by jv_map
I believe it is impossible

clip
Posted: Sat Apr 29, 2006 6:33 pm
by tltrude
Perhaps the beam will go through "player_clip". Then the walls could be nonsolid. You're not saying much about what it is for, but how about making a small hole in the wall?
Posted: Sat Apr 29, 2006 7:24 pm
by Rookie One.pl
I'm afraid I can't reveal much yet. It's for the project I wanted to use pathfinding for. My algorithm worked partially, but I encountered a bit of a problem (would be much easier if sighttracing returned the point hit) and scrapped the idea.
The thing is that I need to display a bot's path before they follow it, and beams would be perfect for it, if only they could be made to work like that (or a valid pathfinding algorithm was used).
Posted: Sat Apr 29, 2006 9:01 pm
by neillomax
I don't know much about it, but what do you use to get a plane to fly around a map ? Can't you do something similar with the function beam ? Make waypoints for it to follow ?
Posted: Sat Apr 29, 2006 9:41 pm
by lizardkid
planes use a number of nodes that have no connection other than a little value saying what's next in the list. he wants a visible line from node to node.
Posted: Sun Apr 30, 2006 8:23 am
by jv_map
Rookie One.pl wrote:(would be much easier if sighttracing returned the point hit)
Use trace maybe?
Posted: Sun Apr 30, 2006 12:51 pm
by Rookie One.pl
I think the picture below explains the pathfinding problem quite well.

While the sight trace fails because of the obstacle, the linear one succeeds. This is not a problem with larger obstacles (I can find a path e.g. around a corner), but quite an issue with smaller ones.
Why is this important? Here is an excerpt of my pathfinding script:
Code: Select all
local.dest = $startnode.origin + (angles_toforward (local.ang + ( 0 local.i 0 ))) * local.dist * -1 // honestly I have no idea why this needs inverting :S
if (sighttrace $startnode.origin local.dest 0 ( -16 -16 18 ) ( 16 16 76 )) {
println "Found at offset " local.i
local.passages[local.pindex] = local.dest
local.pindex++
waitthread draw_beam ($startnode.origin + ( 0 0 32 )) (local.dest + ( 0 0 32 ))
break
} else {
local.dist = vector_length($startnode.origin - (trace $startnode.origin local.dest)) + 32
println "Distance updated to " local.dist
}
Posted: Mon May 01, 2006 10:57 am
by Rookie One.pl
Bump!
I guess I need your help again, jv.

I'm still trying to get it somewhere.

Providing the alpha and a, how do I get the value of b?
Posted: Mon May 01, 2006 4:19 pm
by jv_map
The length of b cannot be determined. One more side or angle needs to be given.
Posted: Mon May 01, 2006 5:08 pm
by Rookie One.pl
Hmm. How about this?

I forgot to mark the beta angle, but it's there between the black and green lines next to alpha.

And alpha contains beta within itself.
c = sin(beta) * a
b = c / sin(alpha)
Would this work?
Posted: Mon May 01, 2006 5:55 pm
by jv_map
Nope,
c != sin(beta) * a
but
c = cos(beta) * a
Similarly,
c = cos(alpha) * b
Such that
b = c / cos(alpha)
Or
b = cos(beta) / cos(alpha) * a
Posted: Mon May 01, 2006 7:15 pm
by Rookie One.pl
Oh.

But hey, I was close, and I haven't had trigonometry yet.

Anyway, thanks a lot, m8.
1 more thing. Can I use your cosinus from Skylimit? You'll be credited, of course.

Posted: Mon May 01, 2006 7:36 pm
by jv_map
Rookie One.pl wrote:Can I use your cosinus from Skylimit? You'll be credited, of course.

Ofcourse, although I can't really take credit for a Taylor expansion
cos x ~ 1 - x^2 / 2! + x^4 / 4! - x^6 / 6! + x^8 / 8! - ...
Where x is in radians.
pi radians = 180 degrees.
The skylimit script takes x in radians, as well.
! denotes a factorial, e.g.
3! = 1x2x3 = 6
Posted: Tue May 02, 2006 2:01 pm
by Rookie One.pl
Thanks. And I've already made the deg->rad conversion, don't worry.

And yes, I do see the light!
