playMaker

Author Topic: Using Raycasts for sword hit detection. Have some questions...  (Read 63 times)

paradiseprime

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
This is the video I am trying to replicate but I am having several issues.
https://www.reddit.com/r/IndieGaming/comments/9tv8gz/started_using_raycasts_for_detecting_if_the/

* I have tried using raycasts but they arent detecting fast movement which is the reason I decided to use them over colliders/triggers. I have the rigid body set to continuous dynamic and it still doesnt trigger every time.

* How is the line gizmo achieved? Its for debugging and uses a raycast line but I dont get how to get it to follow a curve.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4804
    • View Profile
    • jinxtergames
Re: Using Raycasts for sword hit detection. Have some questions...
« Reply #1 on: March 27, 2020, 01:43:21 AM »
Hi to show a line you could edit the raycast script :

add a float value to this line : (float value is the duration it will show the line)
Code: [Select]
Debug.DrawLine(originPos, originPos + dirVector * debugRayLength, debugColor.Value);
this will show line for 3 seconds
Code: [Select]
Debug.DrawLine(originPos, originPos + dirVector * debugRayLength, debugColor.Value, 3.0f);
on the video i do not think it is 'curving a raycast' on the blade there are several short raycasts and due to the drawline delay it looks like its a curve.

paradiseprime

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Using Raycasts for sword hit detection. Have some questions...
« Reply #2 on: March 27, 2020, 02:40:46 AM »
Hi to show a line you could edit the raycast script :

add a float value to this line : (float value is the duration it will show the line)
Code: [Select]
Debug.DrawLine(originPos, originPos + dirVector * debugRayLength, debugColor.Value);
this will show line for 3 seconds
Code: [Select]
Debug.DrawLine(originPos, originPos + dirVector * debugRayLength, debugColor.Value, 3.0f);
on the video i do not think it is 'curving a raycast' on the blade there are several short raycasts and due to the drawline delay it looks like its a curve.

Ahh, thank you. Now the only issue is figuring out why the detection isnt consistent.