Jump to content

[Lua] Loaded Model --> No collision?


NaGo
 Share

Recommended Posts

Hello Forum <3

 

I have a small test scene made in the editor.

Then a model modelled in 3Ds Max(A house with a door and 3 windows-"Very basic"), and assigned a physics file using PhyGen (Collision Tree).

 

Whenever I load the model using the editor Or Lua Script editor, it won't collide with any of the other physics bodies.

 

Well. The 2 boxes collide with eachother, and my scene of course - but Not the model itself.

 

 

--x1
box1Body = CreateBodyBox(1,1,1)
box1 = CreateCube()
box1:SetParent(box1Body)
box1Body:SetPosition(Vec3(0,12,0))
box1Body:SetMass(5)


--x2
box2Body = CreateBodyBox(1,1,1)
box2 = CreateCube()
box2:SetParent(box2Body)
box2Body:SetPosition(Vec3(0.3,24,0))
box2Body:SetMass(5)



hus = LoadModel("abstract::lua_hus01.gmf")                          - Tried LoadMesh too, same thing.
husBody = LoadBody("abstract::lua_hus01.phy",hus)               - (Path, Parent)
hus:SetPosition(Vec3(3,0,0))
hus:SetScale(Vec3(0.2,0.2,0.2))
husBody:SetScale(Vec3(0.2,0.2,0.2))
husBody:SetPosition(Vec3(3,0,0))
husBody:SetMass(5)


--Collision Types
box1Body:SetCollisionType(1)
box2Body:SetCollisionType(1)
husBody:SetCollisionType(1)                                                - Changed this value to several other numbers, including "hus" - Just to try.


grund = LoadScene("abstract::slope.sbx")
grund:SetPosition(Vec3(0,-.5,0))
grund:SetScale(Vec3(2,2,2))

 

Hope it makes sence :)

Link to comment
Share on other sites

when using physics you always have to use LoadModel. With LoadMesh do not use the physics file.

 

You need to set the collision type for each model and then set the collisions for the specified types.

 

See the lua video tutorial: Creating bodies with Lua.

 

You need an extra line that enables collisions between collision types:

Collisions(1,1,1)

Link to comment
Share on other sites

#Paul Thomas:

Here by done. But if you read the last reply, it's hard for me to know the exact info.

 

 

#Aggror:

I'm sorry I didn't include that command in the code above.

I have already added that command, with no help what so ever.

 

And... I have already seen all of your videoes, and they are Very informative( And I love your accent<3 )

 

I'll continue messing around with it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...