Search Unity

Issues with timeScale and collision events...

Discussion in 'Physics' started by The_Arrival, Apr 23, 2015.

  1. The_Arrival

    The_Arrival

    Joined:
    Dec 3, 2014
    Posts:
    82
    Hello Community,

    i´m working on a Tower Defense Game. I have a Tower which shoots a GameObject (Bullet) against Enemys or the ground.

    The BulletObject has a sphereCollider, set to Trigger.
    The Enemys have capsuleCollider, set to Trigger and a Rigidbody (default)
    The Ground has a MeshCollider set to trigger(PlanePrimitive) and a Rigidbody set to kinematic and is frozen to position and rotation.
    Enemys and Ground have the rigidbodys to enable collision with the non-rigidbody bullet.

    i have two of the towers in the exact same spot and every testrun i have the exact same 10 enemys spawning with the same speed.

    i can set Time.timeScale to 0 (pause), 1 (normal), 2 (fast), 4 (very fast). Time.fixedDeltaTime gets NOT set, as the documentation emphasises.

    Expectation:

    no matter what gameSpeed i set, every Time i run the map, i expect the same outcome on enemys killed, damage dealt and so on.

    Results:

    The faster the Gamespeed is, the more enemys die. On normal, 2 are getting through, on fast 0 but it´s close and on very fast also all enemys die, but slightly faster.

    Possible error-source:
    physicscalculations and gameSpeed get out of sync, since i don´t use Time.fixedDeltaTime. Maybe other time values needs to get also synced with my gamespeed.

    Things i tried:
    setting Time.fixedDelta time to the same values like Time.timeScale causes the physics to go nuts. now the bullets don´t collide at all most of the time. Also other collsion based things start to bug.
    All in all ignoring time.fixedDeltaTime seems to be the right aproach, regarding to my tests and my forum/internet researches. Most threads i found suggest ignoring fixedDelta

    But there must be a way to get deterministic simulations, in diffrent gamespeeds, right?
     
  2. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    For start I would log all hit events data (like hit damage, bullet speed etc, ALL whats relevant) with specific time stamps for all different time scales. And then analise that data step by step.