Jump to content

object sinks threw terrain?


Andy Gilbert
 Share

Recommended Posts

Hi, ok in the editor i have my model and in the lua script attatched to the model i have create a spawn function where i create a physics body and give it a mass and parent it to my model, but then with physics on its simply sinks threw the terrain? How do i make it collide with it?

 

Ive tried giving the body a collision type 1, but doesnt seem to do anything?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

You don't need to create a physics body with LUA, just make a phy file with phygen for it.

 

But... if my model is a complex shape the physics seems to be just in the middle of the model and parts of my model go threw the terrain still?? So i though about using a main body and then attatching more bodies to the main, that way i can also add forces on different bodies but on the same model, just in different areas of the model.

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

I think you have multiple physics bodies, if you don't create one with phygen, but create one by code on top of the fixed physics body which Editor creates if you didn't create your own physics body with phygen.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Ok, so how do i retrieve the body that is created by either phygen in lua to add another one?

 

Edit: thiss is what i have...

 

A model that has a phygen file which has a mass of 1.. if i put that in the editor as it is, it slowly falls to the terrain and does a small bounce and stop (all good).

 

If i then enter this into the lua script for the model:

 

dofile("Scripts/base.lua")

function Spawn(model)
local entity=base_Spawn(model)
	body1=CreateBodyBox(0,0,0)
	EntityParent(model,body1)
	body1:SetMass(10)
return entity
end

 

It then falls threw the terrain, if i remove the SetMass line it works ok.

 

 

thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

I think you shouldn't do that, but if you do, you need at least to set EntityType(body1,1). Although I think that command does not exist in LUA. You can't also use physics bodies with smaller than 0.1 dimensions, so your dimension of 0,0,0 will definitely not work.

 

I use only physics shapes created with phygen, it makes life much easier as then I can control their mass and other settings from the properties dialog.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I think you shouldn't do that, but if you do, you need at least to set EntityType(body1,1). Although I think that command does not exist in LUA.

 

I use only physics shapes created with phygen, it makes life much easier as then I can control their mass and other settings from the properties dialog.

 

So.. i cannot create bodyboxes in lua?

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

You probably can, but I think you need then to remove the Editor created static physics body first with LUA code (not from disk, but from the mesh).

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

ok well doing this :

 

dofile("Scripts/base.lua")

function Spawn(model)        
local entity=base_Spawn(model)
	FreeEntity(model)                 
	body1=CreateBodyBox(0,0,0)                
	EntityParent(model,body1)                
	body1:SetMass(10)        
return entity
end

 

Crashes the editor...

 

i think im just going to forget about things for a week or so untill some sort of docs are done or things are sorted as its clearly very unsupported at the moment and obviosuly still has issues...

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

And if you just deleted model, you can't use it anymore. I thought you wanted to parent the body1 to the mesh, somehow like:

EntityParent(entity,body1)

Although I don't know right now how to get the mesh from the entity ;)

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

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...