Page 1 of 1

Universal 'Lookat' for player?

Posted: Fri Jan 17, 2025 1:11 pm
by darkdollgames
Hello! To put it simply, I'd like my player to look at whatever they are interacting with in the level. So, let's say I have a chest, with a Usable component... currently I'm adding an event in the OnUse(), then assigning the Player > Transform > Lookat > then assigning the door object. This works ok, but I'm wondering if there's a better/proper to way to set this up so the player always just looks at a usable when using it? Hope this makes sense! Any help is appreciated

Re: Universal 'Lookat' for player?

Posted: Fri Jan 17, 2025 3:18 pm
by Tony Li
Hi,

If you always want the player to look at the conversant at the beginning of a conversation, you can add a script with OnConversationStart and OnConversationLine methods to the player. Example:

Code: Select all

bool justStartedConversation;
void OnConversationStart(Transform actor) => justStartedConversation = true;

void OnConversationLine(Subtitle subtitle)
{
    if (justStartedConversation)
    {
        justStartedConversation = false;
        subtitle.sequence = $"LookAt(); {subtitle.sequence}"; // Make actor & conversant face each other.
    }
}
If you want the player to look at whatever they interact with regardless of whether they start a conversation or not, then make a subclass of Selector or ProximitySelector. Use the subclass in place of the original on your player. Override the UseCurrentSelection() method. Example:

Code: Select all

public class CustomProximitySelector : ProximitySelector
{
    public override void UseCurrentSelection()
    {
        // << your code here to look at currentUsable >>
        base.UseCurrentSelection();
    }
}