# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Posted: Sun Dec 16, 2012 7:01 am

Joined: Sun Dec 16, 2012 6:52 am
Posts: 1
Currently, I am using a btHeightfield shape to define terrain within my game. It works well, provides the appropriate collision.

However, the characters slide when the slope of the terrain isn't zero. Meaning, when you walk down a gentle hill, gravity still takes place and pulls the character down the gentle hill. I'd like to change this so the slopes don't cause the character to slide, rather just stick to the terrain.

What properties should I look at and try?

I'm using a capsule shape and a btKinematicController and Action for my characters.
I'm using a btHeightfield shape and btRigidBody.

I've attempted to set the Friction of both to one, but it seems to be ineffective.

[SOLVED]

The issue deals with the calculation of the vertical velocity. If you want your character to stick onto slopes and what not (as in, not slide down gradual slopes) then subclass the KinematicController, override the playerStep method, and add the following

Code:

if (!(m_wasOnGround && m_walkDirection.isZero()))
{
m_verticalVelocity -= m_gravity * dt;
if(m_verticalVelocity > 0.0 && m_verticalVelocity > m_jumpSpeed)
{
m_verticalVelocity = m_jumpSpeed;
}
if(m_verticalVelocity < 0.0 && btFabs(m_verticalVelocity) > btFabs(m_fallSpeed))
{
m_verticalVelocity = -btFabs(m_fallSpeed);
}
m_verticalOffset = m_verticalVelocity * dt;
}

The following code will make the character abide by the normal laws of gravity when the player is moving, but when the player is stationary the player will not move at all.

Note that this code worked for generally every case with my playpen, but it might not be optimal for other solutions. I do not know how this responds to such actions as jumping atop static objects, moving platforms, etc.

Top

 Posted: Wed Mar 06, 2013 11:33 pm

Joined: Tue May 01, 2012 10:42 am
Posts: 97
Thanks for posting this, I'm also going to use the same setup, so now I don't have to figure that out anymore thanks

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 7 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities