Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add moving event for locomotion handling #22

Merged
merged 2 commits into from
May 8, 2024
Merged

Conversation

FejZa
Copy link
Contributor

@FejZa FejZa commented May 8, 2024

Reality Collective - Reality Toolkit Pull Request

Overview

So far ILocomotionHandlers have only been notified about a teleportation happening but not free movement. This PR adds a moving event raised whenever free movement is happening, so developers can choose to perform actions upon movement.

This will also be useful in a future release to allow teleportation providers to know that movement is happening. This can be then used to cancel teleportation upon movement and such.

Usage

Method 1: Register a game object handler

public class MovementHandler : MonoBehaviour, ILocomotionServiceHandler
{
    private void Awake()
    {
        ServiceManager.Instance.GetService<ILocomotionService>().Register(gameObject);
    }

    ...
}

Method 2: Use C# event

public class MovementHandler : MonoBehaviour, ILocomotionServiceHandler
{
    private void Awake()
    {
        ServiceManager.Instance.GetService<ILocomotionService>().Moving += LocomotionService_Moving;
    }

    ...
}

@FejZa FejZa requested a review from SimonDarksideJ as a code owner May 8, 2024 17:46
@FejZa FejZa merged commit e389878 into development May 8, 2024
8 checks passed
@FejZa FejZa deleted the feature/moving-event branch May 8, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant