Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

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
0
henrym01
Asked:
henrym01
  • 2
1 Solution
 
MediaMacrosCommented:
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.
0
 
henrym01Author Commented:
any code example please?
0
 
MediaMacrosCommented:
Basically set a variable when you add the model to true.  On the next frame have it get the model and add the modifier, etc.  Then set hte variable back to false.

For collisions this can be a huge subject.  You might try some of hte tutorials here...
http://www.dmu.com/3dd/dd0.html
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now