Wall or object between two points

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Wall or object between two points

Post by Moustache » October 27th, 2010, 7:22 pm

Is it possible to check if there is a wall or an other object between two points?

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Wall or object between two points

Post by Moustache » October 29th, 2010, 2:02 pm

I have changed my question. I hope someone can and will help me :)

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Wall or object between two points

Post by IzNoGoD » October 29th, 2010, 8:14 pm

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
LMGTFY!

Its not a glitch... Its the future!

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Wall or object between two points

Post by Moustache » October 30th, 2010, 9:28 am

Thanks :mrgreen:
That works perfect :!:

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Wall or object between two points

Post by megazor » October 30th, 2010, 12:27 pm

sexier code:

Code: Select all

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

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Wall or object between two points

Post by Moustache » October 30th, 2010, 12:45 pm

:)
I understand that. But the first one is clearer imo.

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Wall or object between two points

Post by megazor » October 30th, 2010, 1:38 pm

ye sure clearer a bit but size wins ^^ coz mine isnt that messed.

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Wall or object between two points

Post by IzNoGoD » October 30th, 2010, 1:49 pm

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... (...)
LMGTFY!

Its not a glitch... Its the future!

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Wall or object between two points

Post by Moustache » October 30th, 2010, 3:31 pm

IzNoGoD his method > megazor his method
:P

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Wall or object between two points

Post by Drofder2004 » October 30th, 2010, 4:32 pm

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.
Image
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

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Wall or object between two points

Post by megazor » October 31st, 2010, 3:28 am

my code calls bullettrace function only one time, so for this case mine works at least not slower than the first code

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Wall or object between two points

Post by IzNoGoD » October 31st, 2010, 8:54 am

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
LMGTFY!

Its not a glitch... Its the future!

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Wall or object between two points

Post by megazor » October 31st, 2010, 9:25 am

i dont understand. "if loop"? lol

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Wall or object between two points

Post by Drofder2004 » October 31st, 2010, 12:14 pm

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.
Image
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

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests