GithubHelp home page GithubHelp logo

Comments (1)

norybiak avatar norybiak commented on September 24, 2024

An actor needs to have an owner when using rigidBodies, otherwise the client side portion of the SDK will not add the actor to the physics bridge, or perform any action such as addForce().

I discovered that when actors are created immediately after the onStarted() event, the SDK fails to properly update each actor's owner once the authoritative user joins. The _rigidBodyDefaultOwner is still undefined at this point.

Actors with rigidBodies for physics simulation require a different method of instantiation than how the sample apps are doing it (e.g. creating actors after onStarted()). This isn't known since there is a lack of documentation on the matter.

The below is an example of a pattern that can be used to assist with getting around the issue mentioned above.

private actorsWithPhysicsCreated = false;

constructor(private context: MRE.Context) 
{
    this.context.onStarted(() => this.createStaticActors());
    this.context.onUserJoined((user) => {

        if (!actorsWithPhysicsCreated) 
            this.initActorsWithPhysics();

        this.userJoined(user);

    });
}

private createStaticActors() {

}

private initActorsWithPhysics() {

    this.actorsWithPhysicsCreated = true;
}

private userJoined(use: MRE.User) {
    
}

For the SDK devs: A better pattern would be for the onStarted() event to fire once the authoritative user is known and the _rigidBodyDefaultOwner property has been defined.

If an actor is intended to be exclusive, it's best to set the the owner manually.

MRE.Actor.Create(this.app.context, {
	actor: {
		exclusiveToUser: user.id,
		owner: user.id,
	}
});

Edit:

"I discovered that when actors are created immediately after the onStarted() event, the SDK fails to properly update each actor's owner once the authoritative user joins. The _rigidBodyDefaultOwner is still undefined at this point."

I found a fix that ensures actors created without owners properly receive the default owner when created within this.context.onStarted(() => .... See the referenced PRs.

from mixed-reality-extension-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.