Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualSteve_Segreto

Posted 01 December 2012 - 02:55 AM

Doesn't normalize(newPos) give you the direction from the collision point back to the player's position? So adding it to the player's position wouldn't be correct then. Maybe you want

Vector2 newPos = fgACollisionP1 - player1Pos;

Not 100% sure though.

EDIT: Nevermind ... I suppose you want the collision response to push the playerPos away from the collision point, so what you've got seems OK.

Maybe the strange rebound is happening from the velocity of the player? Do you need to cross the player's direction vector with the response vector?

See if you can scavenge anything useful out of this stuff from Bullet's character controller:

/*
* Returns the reflection direction of a ray going 'direction' hitting a surface with normal 'normal'
*
* from: http://www-cs-students.stanford.edu/~adityagp/final/node3.html
*/
btVector3 btKinematicCharacterController::computeReflectionDirection (const btVector3& direction, const btVector3& normal)
{
return direction - (btScalar(2.0) * direction.dot(normal)) * normal;
}
/*
* Returns the portion of 'direction' that is parallel to 'normal'
*/
btVector3 btKinematicCharacterController::parallelComponent (const btVector3& direction, const btVector3& normal)
{
btScalar magnitude = direction.dot(normal);
return normal * magnitude;
}
/*
* Returns the portion of 'direction' that is perpindicular to 'normal'
*/
btVector3 btKinematicCharacterController::perpindicularComponent (const btVector3& direction, const btVector3& normal)
{
return direction - parallelComponent(direction, normal);
}

#3Steve_Segreto

Posted 01 December 2012 - 02:48 AM

Doesn't normalize(newPos) give you the direction from the collision point back to the player's position? So adding it to the player's position wouldn't be correct then. Maybe you want

Vector2 newPos = fgACollisionP1 - player1Pos;

Not 100% sure though.

EDIT: Nevermind ... I suppose you want the collision response to push the playerPos away from the collision point, so what you've got seems OK.

Maybe the strange rebound is happening from the velocity of the player? Do you need to cross the player's direction vector with the response vector?

#2Steve_Segreto

Posted 01 December 2012 - 02:46 AM

Doesn't normalize(newPos) give you the direction from the collision point back to the player's position? So adding it to the player's position wouldn't be correct then. Maybe you want

Vector2 newPos = fgACollisionP1 - player1Pos;

Not 100% sure though.

EDIT: Nevermind ... I suppose you want the collision response to push the playerPos away from the collision point, so what you've got seems OK.

#1Steve_Segreto

Posted 01 December 2012 - 02:41 AM

Doesn't normalize(newPos) give you the direction from the collision point back to the player's position? So adding it to the player's position wouldn't be correct then. Maybe you want

Vector2 newPos = fgACollisionP1 - player1Pos;

Not 100% sure though.

PARTNERS