Jump to content

Solved [LE 3.1 Steam] Physics and shape problems


codeape
 Share

Recommended Posts

Hello fellow Leadwerkers

 

I have 2 problems:

 

1. In the editor, I add a box shape to a box and a cylinder shape to a model mesh. I do this with the Physics tab for both visible objects (Scene tab->Physics tab). However, when I enable "VIEW->Show Physics" through the top menu both shapes are shown as cylinders.

 

2. I have a script that creates a top-down perspective of a "Player" in the game. I place a camera over the head of the player and look down and follow the player with the camera. When I add this script to the earlier mentioned model mesh with the cylinder shape the model can go through walls. However, when I add this script on the earlier mentioned box (removing the script from the mesh model first) everything works fine, the box do not go through walls etc. Both the box and the model mesh have the same physics settings in the "Scene tab->Physics tab" with only one exception, The shape is a box for the box and a cylinder for the Model mesh. Here are the rest of the settings in the "Scene tab->Physics tab":

  • Physics mode: Character Controller
  • Mas: 1.0
  • Collision type: Character
  • Character angle: 0.0
  • Swept collision: False
  • Nav obstacle: False

TopDownPerson.lua

test_map.zip

Link to comment
Share on other sites

Seeing your video, yes this is super strange as Character controller should use the cylinder physics and never take account of the model, as the model is just the visual model that just follows the invisible cylnder of character controller.

 

LE3 seems to not like models and physics unfortunatelly (i already reported some similar bugs with models).

 

Could you post your map file ?

 

And i'm interested in your top down controller using mouse ? How do you do that ? Could you post the code ?

Stop toying and make games

Link to comment
Share on other sites

Could you post your map file ?

 

I tried, I do not have permissions for that =(

 

Character controller shape is always Cylindrical.

 

That is no bug as far as i know

 

Ok then bug #1 is almost solved. Should not the shape field in the physics tab be updated to cylinder in that case?

 

How about bug #2 where physics does not work for me. Any ideas?

Link to comment
Share on other sites

Character controller shape is always Cylindrical.

I never said it was a bug , and i'm awar that it's always a cylinder.

 

How about bug #2 where physics does not work for me. Any ideas?

No idea caus it should work, as your character uses the cylinder physics of character controller.

 

Well if you can post your character and camera code, i'll make same scene and test also.

Stop toying and make games

Link to comment
Share on other sites

I may have discovered a thing during browsing my projects directory structure.

 

When I created my project I got a default map called start.map. However I created a new map directly (called test.map) because I wanted to try some things out. However, I ended up creating everything in test.map you see in the YouTube video and the start.map has never been edited. The strange thing is that start.map is 2746 kB big and my test.map is 21 kB. Should my test.map be that small? Is this a problem?

Link to comment
Share on other sites

Ok found the problem.

 

Your code is using SetPosition ,and SetPosition is absolute function that don't care about physics and collisions (good and fast for non collidable stuff)

 

 

 

function Script:UpdatePhysics()
local window = Window:GetCurrent()
...
...
...
-- Move player
local curr = self.entity:GetPosition(true)
curr.x = curr.x + xMod
curr.z = curr.z + zMod
self.entity:SetPosition(curr, true)

 

 

Two main points you'll find on docs or examples :

1) Character controller MUST SetInput function.

2) If you don't need character controller use PhysicsSetPosition to have collision working.

 

--------------------

 

I changed : characterController -> Rigid Body

Collision type ->

Mass = 0.5

click on "Fit Shape"

And using PhysicsSetPosition, the character can't go throught walls.

 

If you need character controller, just take the code for character moving from all examples of "myGame" project.

You have just to use FPS script for key input movement and character move using setInput function.

 

(Can be moved to programming)

Stop toying and make games

Link to comment
Share on other sites

One thing that bother me though is why it worked with SetPosition for the box with physics mode CharacterPhysics but not the Mesh figure that also have physics mode CharacterPhysics.

 

However, I have learned a lot though abut Leadwerks. biggrin.png

Link to comment
Share on other sites

Well , some "Physics settings and collision" doc could help a lot all new comers.

This is lacking, and Physic tab can be confusing when you don't know what to put Scene,Prop,Character controller ... what shapes to use, what functions to call.

Stop toying and make games

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...