Where to put the logic for a grappling hook?

Leorid

New member
Edit: I am using the 3rd person ultimate character controller.

Question seems pretty clear I guess - so I want to create a grappling hook, quite like the one from Worlds Adrift


So once the grapple is attached, the characters Y axis should face the hooks position. (must be something similar to the gravity demo, there the character is also rotating in various angles)
The rope can be expanded and contracted on Input (L-Shift to expand, L-CTRL to contract; when not hooked, L-Shift is for sprinting and L_CTRL for crouching).
Should this be done in an character Ability or ItemAbility?

I have to control the velocity and rotation of the Character -> Ability or ItemAbility? (or something else?)

I need to enable and disable some other abilities, like - the character can't sprint with an attached grapple, the button L-Shift (used for sprinting without grapple) will contract the rope. - Can/Should this be done from within another ability (e.g. grapple ability disables SpeedChange ability while active)? (the state system would be quite good for this, I guess, if it would support turning abilities on and off)

The grapple itself - should it be an item?
I feel like it's more like an ability because it can be used at any time, no matter what weapon is currently equipped.
But it shall use the Aim-Ability (to rotate the character + Body + left Hand towards the point where the grapple should be attached) - but the Aim-Ability IS an ItemAbility ... so I can't use it without an item, right? And when I use it, for example with the AssaultRifle equipped, the character will aim with the assault rifle, not with his left arm, to shoot the grapple, right?

Also this would need override animations, just for the left arm, so he can still hold the currently equipped weapon (but not shoot that weapon during that moment when he fires the grapple hook)

In my specific case, the grapple, once attached to the environment, will be linked to the characters belt - so he has both arms on the currently equipped item - will aiming (with the item, e.g. AssaultRifle) work, when the Y axis is not facing upwards?

Will I have to change something on the camera too? I want the camera to ignore the players rotation entirely.

So basically ... where should I start? I know all of the things mentioned above are possible with this controller, I just don't know how (exactly).
 
Last edited:
This is an interesting question. In this case I would create a new category in the inventory, and then also a dedicated Item Slot on your character that just the grappling hook can use. This will then allow you to still use the Use ability.

When the grapping hook is used it can then start a new ability which controls the character's movement. Items cannot directly control the characters movement so that's why you'll need to start a new ability that does this.

(the state system would be quite good for this, I guess, if it would support turning abilities on and off)
Yes, that's a perfect fit.

Will I have to change something on the camera too? I want the camera to ignore the players rotation entirely.
I don't think that you will but if you do this would be the last thing that I do. An adventure movement type does not determine its location based on the character's rotation.
 
So I create a new ItemType "GrapplingHookT", then assign it to every Slot1 in the ItemSetManager->ItemSet, so it is equipped with every weapon (weapon on Slot0, grapplingHook on Slot1) - then create new ItemAbilities ShrinkRope (Start Type ButtonDown, StopType ButtonUp, InputName: "Shrink Rope") ExpandRope (same as ShrinkRope, with another inputName) as well as adding a second UseItemAbility to my Item Ability List thats activated on rightMouseButtonDown, right?

The second UseAbility then calls Use on the second ItemSlot (Slot1 --> 2nd UseItemAbility-> SlotID: 1) which is then received by the GrapplingHookItemObject, a ShootableWeapon derived class, I guess.
This class can then disable crouchAbility, jumpAbility, speedChangeAbility and enable hookAbility, shrinkRopeAbility, jumpFromHookAbility, expandRopeAbilty (I need those all in seperate abilities, to get the Input for each of them, right?).
All those abilities just send their inputs to the hookAbility, which then controls the characters velocity.

Or can I get multiple Inputs from just one Ability? (L-Shift, L-CTRL, Spacebar, RMB)

Second Slot (Slot1) always has to be set to the GrapplingHookT in order to set the grappling hook as equipped item or is there any way for permanently equipped items/tools?

I can control the characters rotation with UltimateCharacterLocomotion.DeltaRotation and the velocity with ChracterLocomotion.Velocity (+
m_CharacterLocomotion.GravityAmount = 0; to prevent accumulating gravity) - is there anything else I have to consider? any other variables to set, so the character applies the rotation and velocity I set?


Yes, that's a perfect fit.
But right now, it does not support activating and deactivating abilities? I can only set variables in a state-preset - like moveSpeed or IKWeights, not which abilities are enabled or disabled?
 
then create new ItemAbilities ShrinkRope (Start Type ButtonDown, StopType ButtonUp, InputName: "Shrink Rope") ExpandRope (same as ShrinkRope, with another inputName) as well as adding a second UseItemAbility to my Item Ability List thats activated on rightMouseButtonDown, right?
No - I would just create a new ability which changes the rope length. There are a lot of ways that you could accomplish this but the most UCC-like would be to derive a new ItemAction from UsableItem and then override when the item is used. This way you don't need to create a new use ability specifically for one item. In version 2.2 we have a flashlight and that will be a great example of a simple ItemAction to start with (should be released at the start of April).

Or can I get multiple Inputs from just one Ability? (L-Shift, L-CTRL, Spacebar, RMB)
Yes, you can. The EquipUnequip ability uses multiple inputs.

But right now, it does not support activating and deactivating abilities? I can only set variables in a state-preset - like moveSpeed or IKWeights, not which abilities are enabled or disabled?
You can set the Enabled state using the presets.
 
Top