mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Slow down when near other avatars - incremental commit
This commit is contained in:
parent
08e1bfb712
commit
09a6a476d5
1 changed files with 10 additions and 1 deletions
|
@ -320,6 +320,8 @@ void Avatar::setMousePressed( bool d ) {
|
|||
|
||||
void Avatar::simulate(float deltaTime) {
|
||||
|
||||
float nearestAvatarDistance = 1000000.f;
|
||||
|
||||
// update balls
|
||||
if (_balls) { _balls->simulate(deltaTime); }
|
||||
|
||||
|
@ -355,6 +357,8 @@ void Avatar::simulate(float deltaTime) {
|
|||
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
|
||||
|
||||
float distance = glm::length( v );
|
||||
if ( distance < nearestAvatarDistance ) { nearestAvatarDistance = distance; }
|
||||
|
||||
if ( distance < _maxArmLength + _maxArmLength ) {
|
||||
|
||||
closestDistance = distance;
|
||||
|
@ -443,6 +447,11 @@ void Avatar::simulate(float deltaTime) {
|
|||
// decay velocity
|
||||
_velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime );
|
||||
|
||||
// If other avatars nearby, damp velocity much more!
|
||||
if (_isMine && (nearestAvatarDistance < 3.f)) {
|
||||
_velocity *= (1.0 - fmin(10.f * glm::length(_velocity) * deltaTime, 1.0));
|
||||
}
|
||||
|
||||
// update head information
|
||||
updateHead(deltaTime);
|
||||
|
||||
|
|
Loading…
Reference in a new issue