TK_ThrowComponent - golden-coconut-studio/TikiAdventuresWiki GitHub Wiki

ThrowComponent

Component used by ATK_Player characters, whose functionality is to throw either AActor or ACharacter objects.

Acceptance criteria

  • ATK_Player characters can only be thrown if they do not have any other player above them.
  • AActor objects can only be thrown only if they implement the interface UITK_Grabbable whether it is from C++ or blueprints.

Implementation

It is necessary to add this component to a blueprint or C++ class that inherit from ATK_Player.

throw_component

After adding the component, it is required to call the "Throw(EThrowType) function, preferably from an ActionMappings defined in the Input Configuration of the editor (Edit > Project Settings > Input).

input_event

How to use it

There are two ways of throwing: by phyiscs or by launch.

  • If you choose throwing using physics and the thrown object is of type ACharacter, AddImpulse from UCharacterMovementComponent (which is added in ACharacter) will be used.

  • If you choose throwing using physics and the thrown object is of type AActor, the physics of the object will first be enabled

SetSimulatePhysics(true);

And then after enabling physics, Addimpulse from the UStaticMeshComponent of that actir will be used. WARNING: it is recommended to disable physics simulation after finishing the throwing.

  • If you choose throwing using launch and the thrown object is of type ACharacter, LaunchCharacter from the ACharacter class will be used.

  • If you choose throwing with launch and the thrown object is of type AActor, the code will only use physics due to LaunchCharacter not being available in AActor class.

Configuration

These are the options available for configuring the component when clicking on it in the editor:

throw_config

BlueprintCallable

   //This method performs the action of throwing.
   void Throw(UPARAM(DisplayName="Throw Type") EThrowType Type = EThrowType::EThrow_Launch);
   //This method checks the acceptance criteria.
   bool CanThrow();