Jump to content

[SOLVED] Custom player character body and its cylinder physic


tipforeveryone
 Share

Recommended Posts

Hello, I want to create my own Player in Lua, here is my code for its body

 

body = Model:Box()
body:SetShape(Shape:Box())
body:SetMass(20)
body:SetCollisionType(Collision.Character)
body:SetPhysicsMode(Entity.CharacterPhysics)

 

Then I create a Camera and SetParent(body), add some movement controls (AWDS) too.

In debug mode, I use SetDebugPhysicsMode(true) to display physics

 

Compare to Default FPSPlayer, its cylinder physic is so accurate when I move close to an object (Collision.Prop). My character body sometime goes through other objects and its cylinder physic is not accurate.

 

When I release my control key (ex W key), if cylinder physic intersect with an object, my character body will be pushed back a long distance from that object.

 

Can you show me how to make my character body be same as Default FPSPlayer's, to be so accurate

post-16833-0-58043000-1456080125_thumb.jpg

post-16833-0-44789100-1456080134_thumb.jpg

Link to comment
Share on other sites

What are you using for movement? The default FPSPlayer script uses entity:SetInput(). If you are using entity:SetPosition() or similar, it may cause the issues described.

 

Oh I am using entity:Move()

 

if window:KeyDown(Key.W) then body:Move(0,0,0.1) end

 

I will test SetInput() function tonight smile.png thanks for your suggestion

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