Wall or object between two points
Moderator: Core Staff
-
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Wall or object between two points
Is it possible to check if there is a wall or an other object between two points?
-
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Re: Wall or object between two points
I have changed my question. I hope someone can and will help me 

-
- CJ Worshipper
- Posts: 343
- Joined: January 6th, 2009, 8:39 pm
- Location: Netherlands/Holland
Re: Wall or object between two points
Sure is possible
Use this code:
Use this code:
Code: Select all
trace=bullettrace(point1,point2,false,undefined);
if(trace["position"]!=point2)
//there is something between the objects
else
//no wall
-
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Re: Wall or object between two points
Thanks
That works perfect

That works perfect

-
- CJ Worshipper
- Posts: 414
- Joined: July 22nd, 2009, 3:02 am
- Location: Russia, Vladivostok
Re: Wall or object between two points
sexier code:
Code: Select all
if (bullettrace(point1,point2,false,undefined)["position"] != point2)
-
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Re: Wall or object between two points

I understand that. But the first one is clearer imo.
-
- CJ Worshipper
- Posts: 414
- Joined: July 22nd, 2009, 3:02 am
- Location: Russia, Vladivostok
Re: Wall or object between two points
ye sure clearer a bit but size wins ^^ coz mine isnt that messed.
-
- CJ Worshipper
- Posts: 343
- Joined: January 6th, 2009, 8:39 pm
- Location: Netherlands/Holland
Re: Wall or object between two points
megazor wrote:ye sure clearer a bit but size wins ^^ coz mine isnt that messed.
Some credit for FIRST POST!!!!11!!!oneone!!!1 ?
it doesnt really matter which you use, unless you really care for gsc size... (...)
-
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Re: Wall or object between two points
IzNoGoD his method > megazor his method


-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Wall or object between two points
I would personally use the first code. It is just simply better practice to use one function at a time, instead of nesting a function inside a function., although both will work just as well as the other.

Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
- CJ Worshipper
- Posts: 414
- Joined: July 22nd, 2009, 3:02 am
- Location: Russia, Vladivostok
Re: Wall or object between two points
my code calls bullettrace function only one time, so for this case mine works at least not slower than the first code
-
- CJ Worshipper
- Posts: 343
- Joined: January 6th, 2009, 8:39 pm
- Location: Netherlands/Holland
Re: Wall or object between two points
Go put the trace= stuff on the trace position in the if loop. This is what you get:IzNoGoD wrote:Sure is possible
Use this code:Code: Select all
trace=bullettrace(point1,point2,false,undefined); if(trace["position"]!=point2) //there is something between the objects else //no wall
Code: Select all
if(bullettrace(point1,point2,false,undefined)["position"]!=point2)
//wall
else
//no wall
-
- CJ Worshipper
- Posts: 414
- Joined: July 22nd, 2009, 3:02 am
- Location: Russia, Vladivostok
Re: Wall or object between two points
i dont understand. "if loop"? lol
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Wall or object between two points
They are exactly the same code. One is just more aesthetically pleasing than the other.megazor wrote:my code calls bullettrace function only one time, so for this case mine works at least not slower than the first code

Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010