Something went wrong. Try again.
A unity based gravity simulation thing inspired by interplanetary (the game)
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940using Physics.Components;using Unity.Burst;using Unity.Entities;using Unity.Transforms;using UnityEngine;
namespace Physics.Systems{ [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))] [UpdateBefore(typeof(PhysicsSystem))] public partial struct PhysicsSystem : ISystem { [BurstCompile] public void OnCreate(ref SystemState state) { }
[BurstCompile] public void OnUpdate(ref SystemState state) { foreach (var (particle, transform, entity) in SystemAPI.Query<RefRW<Particle>, RefRW<LocalTransform>>().WithEntityAccess() ) { particle.ValueRW.PreviousPosition = transform.ValueRO.Position; particle.ValueRW.Velocity += particle.ValueRO.Acceleration * SystemAPI.Time.DeltaTime; transform.ValueRW.Position += particle.ValueRO.Velocity * SystemAPI.Time.DeltaTime; particle.ValueRW.Acceleration = 0; Debug.DrawLine(particle.ValueRO.PreviousPosition, transform.ValueRO.Position, Color.red, 10f); } }
[BurstCompile] public void OnDestroy(ref SystemState state) {
} }}