public override void RevertableUpdate(float deltaTime) { if (TimeTraceManager.tracing) { return; } if (cc.isGrounded && !isGrounded && deltaTime > 0 && cc.velocity.y < -0.01f) { TimeTraceManager.AddTraceEvent(new LandEvent(velocity)); } isGrounded = cc.isGrounded; float h = 0; float v = 0; if (bLeft) { h = -1; } else if (bRight) { h = 1; } if (bUp) { v = 1; } else if (bDown) { v = -1; } if (isGrounded) { if (!Mathf.Approximately(currentFrameJumpSpeed.y, 0)) { velocity = currentFrameJumpSpeed; } else { velocity = new Vector3(h * speed, 0, v * speed); } } else { currentFrameJumpSpeed = Vector3.zero; } velocity.y += deltaTime * gravity; cc.Move(velocity * deltaTime); }
// Update is called once per frame void Update() { if (!TimeTraceManager.tracing) { directionalInputFactory.CheckForInputEvent(OnDirectionalInput); if (Input.GetKeyDown(KeyCode.Space)) { TimeTraceManager.AddTraceEvent(new JumpEvent()); } } }
private void OnDirectionalInput(InputEventDirectional input) { TimeTraceManager.AddTraceEvent(input); }