protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        float dt = Time.DeltaTime;

        JobHandle myJob = Entities.ForEach((ref PhysicsVelocity vel, in PhysicsMass mass, in MotionComponent motion) => {
            ComponentExtensions.ApplyLinearImpulse(ref vel, mass, motion.direction * motion.speed * dt);
        }).Schedule(inputDeps);
Exemple #2
0
    protected override void OnUpdate()
    {
        if (GameManager.Instance.IsRunning())
        {
            var dt        = Time.DeltaTime;
            var inputData = EntityManager.GetComponentData <CharacterControllerInput>(GetSingletonEntity <CharacterControllerInput>());

            var move = new float3(inputData.Movement.x, inputData.Jumped ? 1 : 0, inputData.Movement.y);
            move *= multiplier * dt;
            inputData.Movement = float2.zero;
            Entities.WithAll <PlayerTagComponent>().ForEach(
                (ref PhysicsVelocity _physicsVelocity, ref PhysicsMass _physicsMass) =>
            {
                ComponentExtensions.ApplyLinearImpulse(ref _physicsVelocity, _physicsMass, move);
            });
        }
    }