And so, you’d make a raycast that hits an invisible sphere that you would put around your grapple-able objects, which would return to your actor the instance of object it hit. From there, you do “Get Transform”, then Break Transform and use that object’s Location as a target for your grappling hook.
To specifically track long edges, something can probably be done with splines but I’m no expert.
As a side note, that grappling hook behavior - doesn’t it look a lot like the system used in the Arkham games?
Hmmm… that’s a good start, but I need something that works in relation to a crosshair. I need the grapple to target grapplable objects closest to where my character is aiming in screen space.
I suppose that I could make each grapplable object within a radius of my character shoot a ray at her. If they hit her, then I could store the angle between her aim vector and the vector from each grapplable object in an array and retrieve the object that generates the smallest angle. That would mean that she would always grapple objects closest to where she is aiming, right?
I think the problem with this system is that the rays will always shoot from the center of each grapplable object. I’ll have to place several grapple points on the surface of each grapplable object so that my character can grapple the edges of objects. I wish there was a way to generate grapple points from vertices.
On top of the cast idea I sent, have the object return the coordinates of a spline that’s part of the object, and have a crosshair render over it. I’m not sure how possible it is, but it would be another step forward.
The grappling system is just an add force node. When my character reaches a certain distance away from the grappling point, it adds a force towards the grappling point. This force is multiplied by how far my character has extended past the desired “rope” distance so that the force functions like a spring or bungee cable. It’s also multiplied by the angle between her velocity vector and the vector aiming at the grappling point. This keeps my character from bouncing too much by only pulling her towards the grappling point when she’s moving away from the grappling point.
It basically acts as an equal and opposite force that keeps her from moving too far away from the grappling point.
Telling from your tweet, it looks pretty smooth. I wasn’t able to reproduce such good feel with my physics constraint way on my Ratchet and Clank series
(https://www.youtube.com/watch?v=XbIsV-Mt9II)
The grapple you made looks pretty great from what I’m seeing. Perhaps mine simply looks smoother due to my custom character/animations along with how she rotates to always point towards the grappling point.