I am starting to find my way into using the DOTS (Data Oriented Technology Stack) method of making objects.
There are several samples all over, Youtube videos and also samples directly from Unity, such as the github repo 'EntityComponentSystemSamples'.
In all of these, I stumble across 'OnUpdate', but never 'OnFixedUpdate'.
Normally, Unity GameObjects would have both, one for each graphics frame update (OnUpdate
), and one for each physics movement update (OnFixedUpdate
).
When trying to create behavior that uses Rigidbody.AddForce(), it was always important to use FixedUpdate().
Has this concept been removed in DOTS? How do I add scripted, varying forces to a PhysicsBody in DOTS ?
Currently, I am adding my force*deltatime
to the Unity.Physics.PhysicsVelocity
in the update.
Every system can belong to a single System Group only. You specify this with attributes.
Attribute [UpdateInGroup(typeof(SimulationSystemGroup))]
makes your OnUpdate
being called as general game/simulation updates. This is a default group for systems.
Attribute [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
makes your OnUpdate
being called in fixed simulation intervals (i.e.: FixedUpdate).
Note: This^ correction is taken from @thelebaron answer. Give him an upvote please.
Attribute [UpdateInGroup(typeof(PresentationSystemGroup))]
makes your OnUpdate
being called in rendering context; before frames are drawn (i.e: Update)
[UpdateInGroup( typeof(SimulationSystemGroup) )]
public class SomeKindOfSimulationSystem : SystemBase
{
protected override void OnUpdate ()
{
/* simulation update */
}
}
[UpdateInGroup( typeof(PresentationSystemGroup) )]
public class SomeKindOfRenderingSystem : SystemBase
{
protected override void OnUpdate ()
{
/* rendering update */
}
}