Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

objectIntersect()

Purpose

Used to check if one 3D object is colliding with another

Syntax

collision = objectIntersect( object1, object2 )

Arguments

collision True or false result depending on whether a collision is taking place

object1 Handle containing the first object

object2 Handle containing the second object

Example

ink(navy)
showObjectBounds( true, white, 1 )

model_1 = loadModel( "Broken Vector/Car3Silver" )
testObj = placeObject( model_1, {}, { 1, 1, 1 } )

model_2 = loadModel( "Kat Deak/Polyhedron_6b" )
objectPos = { 0, 1.5, 5 }
object = placeObject( model_2, objectPos, { 1, 1, 1 } )

setCamera( { -8, 2, 0 }, { 0, 1, 0 } )
worldLight( { 0, -1, 0 }, white, 2 )
setEnvironment( 3, { .1, .1, .1, 1 } )

loop
    clear()
    c = controls(0)

    objectPos += { 0, c.up, c.right } * 0.05
    objectPos -= { 0, c.down, c.left } * 0.05

    setObjectPos( object, objectPos )

    collision = objectIntersect( object, testObj )

    if collision then
        setObjectMaterial( object, red, 0, 1 )
        setObjectMaterial( testObj, red, 0, 1 )
    else
        setObjectMaterial( object, white, 0, 1 )
        setObjectMaterial( testObj, white, 0, 1 )
    endif

    printAt( 0, 0, "Press the directional buttons to move the object" )
    printAt( 0, 2, "Collision: ", collision )

    drawObjects()
    update()
repeat

Associated Commands

drawObjects(), placeObject(), setObjectCollisionScale() setObjectPos(), showObjectBounds()

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.