Search Unity

Resolved How to change gravity on collision with ECS?

Discussion in 'Physics for ECS' started by OzzyC, Aug 5, 2022.

  1. OzzyC

    OzzyC

    Joined:
    Jul 19, 2022
    Posts:
    2
    Hi new to unity and DOTS/ECS. I need to change gravity of a cube when a ball hits it. There is plenty of youtube tutorials showing how to do this but they all use JobComponentSystem to inherrit for their system classes.When I type JobComponentSystem in place of SystemBase its gets a could not be found error with red underline. I am using Unity.Jobs, Physics etc.

    İs there any other way to make this without using JobComponentSystem or why is it not working? Am I missing some package or usings?
     
  2. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    OzzyC and ErezShahaf like this.
  3. ErezShahaf

    ErezShahaf

    Joined:
    Feb 3, 2022
    Posts:
    70
    Cool repository, what does the lambda expression do in
    Code (CSharp):
    1. public Entity EntityA => Entities.EntityA;
    seems like an expression bodied member but I can't understand this specific case
     
  4. OzzyC

    OzzyC

    Joined:
    Jul 19, 2022
    Posts:
    2
    Thank you so much, that realy helped.
     
    Occuros likes this.
  5. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    This is simply to keep the EntityPair internal and create a getter method.

    This code part is taken over from the unity physics examples which can be found here:

    https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/PhysicsSamples

    It is a real treasure for examples and code snippets.