Basically the Controller does a trace from the Pawn towards infront of it.
If it founds something interactable, it has two options:
Either The Pawn moves automatically towards the interactive Object if it is not reachable
Or the Pawn is already in a “tolerance zone” and can interact with it directly
I make use of a so called “Ideal Location”, which describes where the Pawn has to be to interact with the Object.
For example for a button, you need to stand infront of it and also face towards it.
I provde some options, too:
There’s a Timer that defines how long the pawn may move/try to move towards the interactive object.
If the timer elapsed, the pawn may either cancel completely or magically sweeps(through obstacles) to the object.
The Tolerance for Location and Rotation is used to make it easier to interact, since it is impossible to align the player correctly.
For example you may face a button with a 22.5° difference in yaw, but you can still use it.
Once the Pawn is in ideal position, the Interactive Object AND the Pawn play an Animation.
The Animation is determined by the Interactive Object (and can be unique for pawns).
Hey there. I provided an Interface called “InteractAnimationInterface”.
Let your Pawn/Character implement this Interface.
This Interface provides an Event “PlayAnimation” with the same signature like your CustomEvent and is used to play the InteractAnimation.
Sidenote: Only Characters have the ability to play Montages directly. A Pawn different than Character needs a different Method for playing Montages. This is what the Interface is for.
The Tolerance is set in the Controller, and is separated in LocationTolerance and RotationTolerance.
The button defines the Location in “getIdealLocation” where the character has to be to use the button. (Tolerance from the Controller will be applied when you try to use it)