Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: paradiseprime on March 26, 2020, 11:38:13 PM

Title: Using Raycasts for sword hit detection. Have some questions...
Post by: paradiseprime on March 26, 2020, 11:38:13 PM
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/ (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.
Title: Re: Using Raycasts for sword hit detection. Have some questions...
Post by: djaydino on March 27, 2020, 04: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.
Title: Re: Using Raycasts for sword hit detection. Have some questions...
Post by: paradiseprime on March 27, 2020, 05: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.