TK_ThrowComponent - golden-coconut-studio/TikiAdventuresWiki GitHub Wiki
ThrowComponent
Component used by
ATK_Player
characters, whose functionality is to throw eitherAActor
orACharacter
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 interfaceUITK_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
.
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).
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 theACharacter
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 toLaunchCharacter
not being available inAActor
class.
Configuration
These are the options available for configuring the component when clicking on it in the editor:
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();