Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I've made a bounce script, but don't know how to optimize
#4
Update! 
I reduced the complexity by calling actor.AddForce the negative force that I would add to character (trampoline force).
This iteration no need to query anything.

Code:
        private void FixedUpdate()
        {
            if (bounceForce != default) {
                actor.AddForce(bounceForce, ForceMode.Impulse);
                if (_debug) Debug.Log($"{name} add {bounceForce.ColorMe(kColor.orange)} force to {actor.GetType().Name}!");
                bounceForce = default;
            }
        }


Reply


Messages In This Thread
RE: I've made a bounce script, but don't know how to optimize - by spikebor - 01-05-2024, 04:39 PM