I’m trying to get a grapple hook working. I’ve reviewed the code and have narrowed it down to these 3 situations where there should be a mistake. Else there must be some kind of demon cursing me.
Grapple blueprint:
Every tick, if my hook hit something, a force is applied to me towards the hook. If I get close to the hook, it breaks. If I pass it, it breaks.
On grapple hit:
When the grapple hits a surface, my ground friction and gravity scale get set to 0 to facilitate lift off and air control is increased. To take off I get an initial pull (velocity). Don’t worry about initial hook direction 2d.
To grapple hook:
When the hook is attached to a surface, I subtract its location to mine, thus getting the vector going from my position to the hook. I then normalize this vector to have it be easily scalable.
My problem is that as soon as my grapple hits I do get launched, but in the wrong direction. That is, the x and y components of the direction are correct, but the z isn’t. I get launched upwards and a little towards the hook in a parabolic manner.
I checked the To Grapple Hook direction by tracing it. It’s correct. I’m completely lost.
Hello,
I wanted to help but your setup is perfectly fine and working well for me. There is no error in code you posted here. Problem should be somewhere else.
A wild guess would be to check collision on your grappling hook. If there is a collision on the hook rope your character might be just stumbling over it. Try disabling collision of the hook/rope.
No collision on the rope. I tried changing the add force node to a set velocity node. That way I get precisely ‘moved’ to where the hook is. The downside of this is that I don’t have air control and it feels clunky.
A couple of blindly obvious suggestions, but they may give outcomes similar to what U describelll perhaps worth a few minutes to double check.
Gravity - I check your project’s gravity settings, and that the force is large enough to overcome normal gravity. You can swiftly throw some vast numbers there to test.
Target Location - Ensure that the root location of your grappling hook actor is where it should be. If it’s at the bottom of the rope or something. Again, you can move around the target location, to test this too.
State - Something might be changing the state prematurely, which would turn off the force.
Thanks for your suggestions. I’ve done as you suggested but couldn’t find any anomalies. The gravity is set to 0 as soon as the grapple hits anything. The target location is indeed correct and nothing changes the state. I’ve gone ahead and manually set the state to falling just in case.
I noticed that by decreasing the force multiplier and unplugging the initial velocity bump (respectively in event graph and OnGrappleHit) the effect is much less noticeable. By plugging the initial velocity back in and unplugging the z component of the force, the effect is the same as described in the original post.