Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Sword collision phsyics

Discussion in 'Physics' started by XJonOneX, May 14, 2023.

  1. XJonOneX


    Dec 19, 2017
    I'm prototyping a sword fighting game, and I obviously need to detect when swords collide. For prototyping purposes, collision for the swords is always on. The swords have a box collider with IsTrigger true, and RigidBody with IsKinematic true.

    This works out great, but not all the time. Right now I'm playing a swing animation against a stationary sword prop for collision development.

    In the video below, you can see the yellow lines are drawn when OnTriggerStay is called. I also tried it in Update after using OnTriggerEnter to enable the line drawing and OnTriggerExit to disable it. I get the same results.

    I get what's happening. OnTriggerEnter isn't being called because the sword doesn't collide inbetween frame updates.

    My question is, how can I do a sweep detection between the last position from the last frame, to the current position in the current frame? So I can catch these instances where the sword never collides from one frame to the next.