Jump to content

Recommended Posts

Posted

ANSWERED

 

Hi, I just bought this engine a couple of days ago. It's really nice so far, but the physics engine is kind of glitchy. There have been other posts on the physics engine, and so I am aware the developer is working on it. BUT, the game I am looking to make doesn't need any sort of physics; I just need collision. Unfortunately, I can't seem to collide with anything if the mass is set to 0. If I enable physics, I can't seem to get it to not move, and It goes through everything. SO, does anyone have an idea?

 

*EDIT: I am using a rigid body character, not a character controller.

Posted

I'm not using a character controller, I can't customize the character controller at all. I'm making a 2.5d platformer, and I'm using a rigid body for the player (without mass).

Posted

Found a solution. I just had to use SetPosition() instead of PhysicsSetPosition(), and then I could have physics on without the player being moved when I didn't want him to.

  • Upvote 1
Posted

I know it will take a while but I'm really curious what you come up with. One of my inspirations is another Leadwerks 2.5d platformer: http://www.leadwerks.com/werkspace/files/file/278-the-last-chapter/

You probably can't download it as it was an LE2 project but take my word that it's pretty cool.

The other bigger one is Trine / Trine 2 but that involves physics and control that I don't think Leadwerks can do yet.

Posted

Ok, so it turns out that method had a lot of collision bugs. I then came up with a new solution that uses the physics, and it (almost) works, but it is really weird. The physics for the player are so jittery it makes the game virtually unplayable. I don't think it's lag, either, because the frame rate is about 180! I'll put up the project in a moment; It'll take a while to upload.

Posted

trine was made with leadwerks?

Whoops, no. Didn't mean to imply that.

 

There was a thread today about physics. I think the jitter involved using two functions together that shouldn't be (maybe one physics and one not). Couldn't find it at the moment.

 

Thanks for the project link. Will check it out at home.

Posted

Your call to SetRotation() is resetting the entity physics each frame, and it's also called in UpdateWorld() instead of UpdatePhysics(), where it should be (if at all): I changed the command to PhysicsSetRotation() which will do the same thing by applying torque to the object.

local window = Window:GetCurrent()

 

local onGround = false

 

function Script:Start()

x = self.entity.position.x

y = self.entity.position.y

z = self.entity.position.z

end

 

function Script:UpdatePhysics()

 

window = Window:GetCurrent()

 

if window:KeyDown(Key.D) and not cRight then

self.entity:SetVelocity(Vec3(10, self.entity:GetVelocity().y, 0))

elseif window:KeyDown(Key.A) and not cLeft then

self.entity:SetVelocity(Vec3(-10, self.entity:GetVelocity().y, 0))

end

 

if window:KeyDown(Key.W) and onGround then

self.entity:AddForce(0,500,0,true)

end

 

--self.entity:SetRotation(0, 0, 0)

self.entity:PhysicsSetRotation(0, 0, 0)

self.entity.position.z = -6.0

 

onGround = false

end

 

function Script:Collision( entity, position, normal, speed )

 

--print(normal.y)

 

if normal.y > 0.0 then

onGround = true

end

 

end

 

You will always have problems if you try to make a rigid body behave like a character controller, because a character controller is fundamentally unrealistic...it always points straight up and down and can't rotate around the XZ axes. Even if you use a force to try to change the orientation, that force will have other unintended effects.

 

The character controller is specifically designed for this type of movement and should really be used here. There are previous projects that used it in this way.

My job is to make tools you love, with the features you want, and performance you can't live without.

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.

×
×
  • Create New...