FANDOM



This command will return the distance to the point of intersection between two coordinates, in reference to the specified object.

Syntax
Return Float=INTERSECT OBJECT(Object Number, X, Y, Z, ToX, ToY, ToZ)
Parameters
Object Number

Integer
The object number to check X Float
The from x position Y Float
The from y position Z Float
The from z position ToX Float
The to x position ToY Float
This value is a float number such as 0.5 ToZ Float
This value is a float number such as 0.5

Returns

This value is a float number such as 0.5

Description

Use this command to project a line from your current position to a destination to determine whether a collision will occur with an object. Ideal for bullet calculations and fast manual polygon collision.

Example Code
sync on : sync rate 60 : hide mouse:cls 0

autocam off

set global collision on

ObjectNumber=1

SecondObject=2

make object sphere ObjectNumber,10

color object ObjectNumber,rgb(0,255,0)

position object ObjectNumber, 0,0,0

make object cone secondObject,10

xrotate object secondObject,90

fix object pivot secondObject

color object SecondObject,rgb(255,0,0)

position object SecondObject, 15,0,0

AUTOMATIC OBJECT COLLISION ObjectNumber,5,1

AUTOMATIC OBJECT COLLISION SecondObject,5,1

while mouseclick()=0

set cursor 0,0

if leftkey()=1 then turn object left SecondObject,1

if rightkey()=1 then turn object right SecondObject,1

if upkey()=1 and OBJECT HIT(SecondObject,0)=0 then move object SecondObject,1

if downkey()=1 and OBJECT HIT(SecondObject,0)=0 then move object SecondObject,-1

if returnkey()=1 then position object SecondObject,15,0,0

if OBJECT COLLISION(SecondObject,0) then print "OBJECT COLLISION"

xp=object position x(SecondObject)

yp=object position y(SecondObject)

zp=object position z(SecondObject)

nxp=newxvalue(xp,object angle y(SecondObject),50)

nzp=newzvalue(zp,object angle y(SecondObject),50)

print INTERSECT OBJECT(ObjectNumber,xp,yp,zp,nxp,0,nzp)

position camera object position x(SecondObject),object position y(SecondObject)+50,object position z(SecondObject)

point camera object position x(SecondObject),0,object position z(SecondObject)

sync

endwhile

set global collision off

delete object ObjectNumber

delete object SecondObject

end
Community content is available under CC-BY-SA unless otherwise noted.