Page 1 of 1

Wall or object between two points

Posted: October 27th, 2010, 7:22 pm
by Moustache
Is it possible to check if there is a wall or an other object between two points?

Re: Wall or object between two points

Posted: October 29th, 2010, 2:02 pm
by Moustache
I have changed my question. I hope someone can and will help me :)

Re: Wall or object between two points

Posted: October 29th, 2010, 8:14 pm
by IzNoGoD
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

Re: Wall or object between two points

Posted: October 30th, 2010, 9:28 am
by Moustache
Thanks :mrgreen:
That works perfect :!:

Re: Wall or object between two points

Posted: October 30th, 2010, 12:27 pm
by megazor
sexier code:

Code: Select all

if (bullettrace(point1,point2,false,undefined)["position"] != point2)

Re: Wall or object between two points

Posted: October 30th, 2010, 12:45 pm
by Moustache
:)
I understand that. But the first one is clearer imo.

Re: Wall or object between two points

Posted: October 30th, 2010, 1:38 pm
by megazor
ye sure clearer a bit but size wins ^^ coz mine isnt that messed.

Re: Wall or object between two points

Posted: October 30th, 2010, 1:49 pm
by IzNoGoD
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... (...)

Re: Wall or object between two points

Posted: October 30th, 2010, 3:31 pm
by Moustache
IzNoGoD his method > megazor his method
:P

Re: Wall or object between two points

Posted: October 30th, 2010, 4:32 pm
by Drofder2004
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.

Re: Wall or object between two points

Posted: October 31st, 2010, 3:28 am
by megazor
my code calls bullettrace function only one time, so for this case mine works at least not slower than the first code

Re: Wall or object between two points

Posted: October 31st, 2010, 8:54 am
by IzNoGoD
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
Go put the trace= stuff on the trace position in the if loop. This is what you get:

Code: Select all

if(bullettrace(point1,point2,false,undefined)["position"]!=point2)
                //wall
else
                //no wall
exactly your code

Re: Wall or object between two points

Posted: October 31st, 2010, 9:25 am
by megazor
i dont understand. "if loop"? lol

Re: Wall or object between two points

Posted: October 31st, 2010, 12:14 pm
by Drofder2004
megazor wrote:my code calls bullettrace function only one time, so for this case mine works at least not slower than the first code
They are exactly the same code. One is just more aesthetically pleasing than the other.