Re: How to setup entity collision in C#

#2
If you have your EntityComponent you can Physicalize it by calling the Physicalize-method on the Physics property of the EntityComponent. For the RollingBall template it works like this for example:

Code: Select all

var physicsEntity = Entity.Physics; if(physicsEntity == null) { return; } // Physicalize the Entity as type Rigid. // This physical entity type is specifically implemented for objects that can move around (so not static). physicsEntity.Physicalize(Mass, EPhysicalizationType.ePT_Rigid);
Moving the object can be done by using the Impulse property on the PhysicsEntity, or by calling the Action<> method on the PhysicsEntity. Example:

Code: Select all

var physics = Entity.Physics; if(physics == null) { return; } //Using the impulse property physics.Impulse = Vector3.Forward * frameTime; //Using the Action<> method physics.Action((Common.pe_action_impulse action) => { action.impulse = Vector3.Forward * frameTime; });
I know this isn't currently the most intuitive way to work with physicalized entities, so let me know if you need more help.
We are currently working on more C# templates which will also bring with it a few upgrades on Physicalize and moving physical-entities so it becomes a bit more intuitive.

Re: How to setup entity collision in C#

#4
This could be caused by a missing surface-type for the designer objects. Can you check if you have a surfacetypes.xml file in you assets folder? It should be in Assets/libs/materialeffects/surfacetypes.xml. From what I remember the designer objects use the default surface type, so make sure there is a definition for a mat_default surfacetype. If you open the surfacetypes.xml file in a text-editor like notepad++ you can see which types are already defined.
My (very simple) surfacetypes.xml looks like this:

Code: Select all

<SurfaceTypes> <SurfaceType name="mat_default"> <Physics sound_obstruction="0.5" /> </SurfaceType> <SurfaceType name="mat_canopy"> <Physics sound_obstruction="0.5" /> </SurfaceType> <SurfaceType name="mat_bullet"> <Physics friction="0.1" /> </SurfaceType> </SurfaceTypes>
If the xml file is missing you can create a new one manually and paste the above xml-code in there.

Who is online

Users browsing this forum: No registered users and 4 guests