Jump to content
  • Advertisement
Sign in to follow this  
Alundra

Actor-Components physic issue because of design

This topic is 558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Edited by Alundra

Share this post


Link to post
Share on other sites
Advertisement

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 ?

This sounds like it would work. Do you have any specific concerns about why you don't think it will?

Share this post


Link to post
Share on other sites

This is my best guess to have a clean and working solution, I asked in case I didn't think of one thing but apparently it sounds like a solid solution.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!