Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / If object within?

Author
Message
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 31st Aug 2010 03:04
is there a command like that? something like
"if object within(objnumber,x,y,z,x,y,z) then ..."
which is pretty much saying if the object is withing x,y,z to x,y,z then do something.
Is there a command like that? if not how would I do that?

I want coke, not Pepsi!
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 31st Aug 2010 03:41
How about using < and >.


My computer surpasses all the technologies of the day. What computer do I have?

CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 31st Aug 2010 03:54
Ok how are we defining X1 and X2?

I want coke, not Pepsi!
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 31st Aug 2010 05:12 Edited at: 31st Aug 2010 05:12
Looking at his code, it looks like:

x1 = left side of the box.
x2 = right side of the box.

y1 = bottom of the box
y2 = top of the box

z1 = back of the box
z2 = front of the box


where "the box" defines the area that the object has to be within.


Guns, cinematics, stealth, items and more!
Omen
19
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 31st Aug 2010 05:38 Edited at: 31st Aug 2010 05:38
You could use the zone commands in IanM's MatrixUtils.

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18

...specifically the command you want is "Point in Zone"

http://www.matrix1.demon.co.uk/Matrix1Utils_Help/Matrix1Util_21/point_in_zone.html

CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 31st Aug 2010 07:16 Edited at: 31st Aug 2010 07:17
Quote: "Looking at his code, it looks like:

x1 = left side of the box.
x2 = right side of the box.

y1 = bottom of the box
y2 = top of the box

z1 = back of the box
z2 = front of the box


where "the box" defines the area that the object has to be within."


would you mind testing that quickly? To see if that is how it works? I am very tired and have to get to bed for school.

EDIT: I just reread his code and yeah what you said makes sense.

I want coke, not Pepsi!
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 31st Aug 2010 16:08
Well actually I meant the x1,y1,z1,x2,y2,z2 as the space defining where the box was within.
Wrote a short function and some demo code.


My computer surpasses all the technologies of the day. What computer do I have?

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 31st Aug 2010 20:44
Or use the object hit and object collide commands.

My signature is NOT a moderator plaything! Stop changing it!
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 31st Aug 2010 22:07
But that doesn't work completely because if one object isn't entirely inside the other collision is still detected.

My computer surpasses all the technologies of the day. What computer do I have?

CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 1st Sep 2010 03:04
Thats mad scientist so
X1 = left side of the box
X2= right
Y1 down
y2 up
z1 in
z2 out?

I want coke, not Pepsi!
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Sep 2010 03:14 Edited at: 1st Sep 2010 03:15
Quote: "Thats mad scientist so
X1 = left side of the box
X2= right
Y1 down
y2 up
z1 in
z2 out?"


Yes, but he reversed it in his last example...


Guns, cinematics, stealth, items and more!
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 1st Sep 2010 07:05
Ok but my was IS correct?

I want coke, not Pepsi!
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Sep 2010 07:43
I swear there is some funky cross product mathematics for doing this sort of thing. I wouldn't know how though

The <> method will do the job though

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 1st Sep 2010 15:50
Yeah, to use my function you have to put the larger coordinates first, then the smaller otherwise it gets all messed up.

My computer surpasses all the technologies of the day. What computer do I have?

Login to post a reply

Server time is: 2026-07-24 23:12:40
Your offset time is: 2026-07-24 23:12:40