A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Gaetan » Fri Mar 18, 2011 3:28 pm
Hi,
I'd like to know how to set up a jump functionnality in the Character Controller. Any ideas ?
Thanks,
Gaetan
-
Gaetan
-
- Posts: 4
- Joined: Fri Mar 18, 2011 3:26 pm
by KingSnail » Sat Mar 19, 2011 10:49 am
There is a bug or something with character not jumping because of its stair height. I dunno if its still there
but I had this in my code for a long time and it works fine
- Code: Select all
//This resets controller settings to normal upon landing, this is a newton bug fix by me
if(ace->m_playerState == CustomPlayerController::m_onFreeFall)
{
dVector size((*itx)->Height, 0.0f, 0.0f);
ace->m_stairHeight = ace->m_playerHeight * (1.0f / size.m_x);
}
if(ace->m_playerState == CustomPlayerController::m_onLand)
{
if((*itx)->JumpTimer.GetTime() >= 300.0f && (*itx)->SpacePressed)
{
dVector a(0.0f, PLAYER_JUMP_DISTANCE, 0.0f);
dVector b((*itx)->x, (*itx)->y, (*itx)->z);
ace->m_stairHeight = 0.0f;
NewtonBodyAddImpulse(ace->BODY, &a.m_x, &b.m_x);
(*itx)->JumpTimer.Initialize();
}
}
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by Gaetan » Sun Mar 20, 2011 9:41 am
Thanks you very much KingSnaill!
However I'm unsure on where to put/adapt this code - did you directly modify the Newton library or is it in your project?
Thanks,
Gaetan
-
Gaetan
-
- Posts: 4
- Joined: Fri Mar 18, 2011 3:26 pm
by KingSnail » Mon Mar 21, 2011 6:10 am
The only thing you need to modify is the character controller header in packages/joint lib
modify it so a couple of variables you need a public or make get/set accessors.
The rest is in my main update loop
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by Gaetan » Wed Mar 23, 2011 1:36 pm
Cheers I'll try that!
Thanks,
Gaetan
-
Gaetan
-
- Posts: 4
- Joined: Fri Mar 18, 2011 3:26 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest