Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Struggling with Explosionforce on my non-moving RigidbodyFPSController

Discussion in 'Physics' started by mstyphoon12, Mar 14, 2018.

  1. mstyphoon12

    mstyphoon12

    Joined:
    Mar 14, 2018
    Posts:
    4
    Using the RigidbodyFPSController that comes in the standard unity character asset package I have found that unless I am already moving my character they will be totally unaffected by an explosionforce effect.

    Here is the code for my explosionforce object.
    I feel like this code is not a problem however and it is something in the stock player asset code that is limiting me, as other rigidbody objects react correctly to the same explosionforce effect. Can anyone help me with this? My character reacts properly when they are already moving, it's only when they are not moving at all is there no effect.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    How much force have you tried applying? My first guess is just that the player's static friction is strong enough to overcome the force you're applying, but the dynamic friction is not. Have you tried really increasing the explosive force, like 1000x stronger than normal?
     
  3. mstyphoon12

    mstyphoon12

    Joined:
    Mar 14, 2018
    Posts:
    4
    Just tested your suggestion with increasing my projectile's power from 20 to 20000; It moved me so fast that the individual component's of my player's weapon began to shake violently. However it did nothing to to the player when they weren't moving at all still.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Looks like it's specifically a behavior of the RigidbodyFirstPersonController from Standard Assets. It's this part of the FixedUpdate():

    Code (CSharp):
    1. if (!m_Jumping && Mathf.Abs(input.x) < float.Epsilon && Mathf.Abs(input.y) < float.Epsilon && m_RigidBody.velocity.magnitude < 1f)
    2. {
    3.     m_RigidBody.Sleep();
    4. }
    That's causing the rigidbody to be temporarily ignored until something "wakes" it up. Forces actig on the rigidbody are supposed to wake it up, but that doesn't seem to be happening.

    I'd probably just comment out that Sleep() call. It seems to be there for performance reasons, though it's possible the movement behavior will change a little.
     
    mstyphoon12 likes this.
  5. mstyphoon12

    mstyphoon12

    Joined:
    Mar 14, 2018
    Posts:
    4
    Thankyou! commenting the rigidbody_sleep solved my problem!