Link to home
Start Free TrialLog in
Avatar of henrym01
henrym01

asked on

Lingo Error: 3D cloned object...

Hi Experts, Was wondering if you could help.............

I have created a 3d scene and cloned a character in from the cast, this character is able to navigate around the screen, however im attempting to make it so when it walks into the blocks they will be solid, i added a collision code to try but get a error on the pMouse lines, yet recieve the error:

---------------------------------------------------
Script error: Object expected
pMouse.addmodifier(#collision)
---------------------------------------------------

Does anyone know how to fix this so it relates to a model cloned in?



To clone the model i used:

---------------------------------------------------
pMouse = pMember.cloneModelFromCastmember("mouse", "mouse", member("mouse"))
pMouse.transform.scale = vector(0.2,0.2,0.2)
pMouse.transform.rotation = vector(0,90,0)
pMouse.transform.position.y = -10
pMouse.transform.position.x = 80
pMouse.transform.position.z = 40
---------------------------------------------------

then to detect collision i tried the following:

---------------------------------------------------
-- add collision modifier to the "wall"
pMember.model("block").addmodifier(#collision)

-- set bounding geometry for collision detection to bounding box of model
pMember.model("block").collision.mode = #box

-- resolve collision for wall
pMember.model("block").collision.resolve = TRUE

-- i get the error on the following line

-- add collision modifier to the character
pMouse.addmodifier(#collision)

-- set bounding geometry for collision detection to bounding box of model
pMouse.collision.mode = #mesh

-- resolve collision for character
pMouse.collision.resolve = TRUE

end
---------------------------------------------------


Thank You
Avatar of MediaMacros
MediaMacros

Try a put to see what pMouse registers as.  You may need to wait for a full exitFRam refresh and grab the model by name instead.  

Also, its better to use a dummy box for collisions.  Its far faster and more accurate.  Also, Director's built in collision is poor at best.  You might consider havok or ray casting instead.
Avatar of henrym01

ASKER

any code example please?
ASKER CERTIFIED SOLUTION
Avatar of MediaMacros
MediaMacros

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial