Does anyone know how to do edge detection in unity 3d

Viewed 27

I am trying to recreate several abilities of the spider-man ps4 game. I already got webswinging done and i am currently trying to do the webzipping. I dont have a problem with the zipping itself it's the edge detection. I've tried several solutions but none has worked. Maybe someone has an idea of how to do it and if possible a snippet of code?

2 Answers

Like the edge of a viewport or the edge of another object if so then use collision detection with colliders. Based on OnCollisionEnter etc. Also, choose proper rigid body physics settings suitable for your needs, If u want to check if a specific object collides with an edge of another check their name or set a tag and check it in OnCollider method.

Add colliders to the object you want the web to attach to, and add a collider to the part of the web that hits the object. if you have already done that then maybe the colliders are a bit messed up. Use the OnCollisionEnter3D or OnTriggerEnter3D method to detect collisions. OnCollisionEnter3D checks if the object the script is attached to has touched any collider thats not a trigger and OnTriggerEnter2D checks if it touched any collider thats a trigger

hope this helps!

Related