Hi,
I have a simple and classical design of actor with components, the actor is basically a container of the components.
I have the event of physx's scene calling virtual of the actor connected to the physic shapes (OnCollision, OnTriggerEnter, OnTriggerExit).
I only have one physx's scene which handle all, Scene doesn't contains an instance of physx's scene.
All works fine but the issue is about the spawn because basically here what I do :
ActorWithPhysicComponent* Actor = new ActorWithPhysicComponent;
Actor->SetPosition( Vector3( 10.0f, 20.0f, 30.0f ) );
Scene.AddActor( Actor );
The problem is the actor is created with the component inside it and the physic is linked to physx, it's created on the location (0, 0, 0) and if something is there the callback of physx is called.
What is the best design, surely based on experience, to have a good process about this kind of issue ?
One virtual called OnAddedInScene and called on each component to notify and activate the physic ?
One another virtual called OnRemovedFromScene to disable in the other case ?
Doing that means the physic is only working if the actor is in a scene but the physx stuff is created and linked.
It's already the case for the rendering, if an actor is not in a scene it's not rendered.
Thanks