public override void setSettings(PhysicsSettings newSettings) { stepUpMax = newSettings.stepUpMax; jumpSpeed = 2 * newSettings.apexHeight / newSettings.timeToApex; gravity = jumpSpeed / newSettings.timeToApex; collidables = newSettings.collidables; collisionRadius = newSettings.collisionRadius; maxAngle = newSettings.maxStandingSlopeAngle; }
public override void setSettings(PhysicsSettings newSettings) { physicsSettings = newSettings; collisionRadius = physicsSettings.collisionRadius; collisionHeight = physicsSettings.collisionHeight; stepUpMax = physicsSettings.stepUpMax; maxSlopeAngle = physicsSettings.maxStandingSlopeAngle; collidables = physicsSettings.collidables; }
public void SetManager(ManageGame m) { mgmt = m; phys = m.GetPhysics(); input = m.input; rb.gravityScale = phys.dinogravityscale; rb.mass = phys.dinomass; }
private void Initialize() { if (!character) { character = Find("Character"); } if (!settings) { settings = CreateInstance <PhysicsSettings>(); } if (!Data) { Data = CreateInstance <PhysicsData>(); } Data.OnInitialize(settings, ref character); }
public Level(BonsaiGame game, EventBus eventBus) : base(game) { keyListeners = new List <KeyPressListener>(); this.eventBus = eventBus; this.eventBusSubscriptionIds = new List <string>(); chunkMap = new ChunkMap(10, 10, 10, 10); physSettings = new PhysicsSettings { Gravity = 5f, PhysicsType = PhysicsType.Platformer, Friction = 0.1f, TerminalVelocity = 200f, }; }
// Start is called before the first frame update void Awake() { DontDestroyOnLoad(gameObject); //dumb way to initalize this dinos = new DinoParams[4]; dinos[0] = new DinoParams(0, "Jerry", DinoParams.AIType.player, defaultdinos[0], this); dinos[1] = new DinoParams(1, "Paul", DinoParams.AIType.stupid, defaultdinos[1], this); dinos[2] = new DinoParams(2, "Adelaide", DinoParams.AIType.stupid, defaultdinos[2], this); dinos[3] = new DinoParams(3, "Pinecone", DinoParams.AIType.stupid, defaultdinos[3], this); //references to other scripts options = new GameOptions(); physics = GetComponent <PhysicsSettings>(); input = GetComponent <InputScript>(); SceneManager.LoadSceneAsync(scenePath, LoadSceneMode.Single); }
protected override void OnCreateManager(int capacity) { Settings = PhysicsSettings.LoadFromResources(); _physicsSystems = new List <ComponentSystemBase>(); _physicsSystems.Add(World.GetOrCreateManager <GlobalGravitySystem>()); _physicsSystems.Add(World.GetOrCreateManager <RigidBodySystem>()); _physicsSystems.Add(World.GetOrCreateManager <UpdateColliderPoseSystem>()); _physicsSystems.Add(World.GetOrCreateManager <ComputeColliderAABBSystem>()); _physicsSystems.Add(World.GetOrCreateManager <BroadphaseSystem>()); _physicsSystems.Add(World.GetOrCreateManager <ContactsGenerationSystem>()); _physicsSystems.Add(World.GetOrCreateManager <ConstraintSolverSystem>()); for (int i = 0; i < _physicsSystems.Count; i++) { _physicsSystems[i].Enabled = false; } }
public override bool Equals(object obj) { if (obj is WorldEntity) { WorldEntity w2 = obj as WorldEntity; if (!PhysicsSettings.Equals(w2.PhysicsSettings)) { return(false); } if (WorldInfo.Equals(w2.WorldInfo)) { return(false); } foreach (var e1 in WorldElements) { bool contains = false; foreach (var e2 in w2.WorldElements) { if (e1.Equals(e2)) { contains = true; break; } } if (!contains) { return(false); } } return(true); } return(base.Equals(obj)); }
public void setPhysicsSettings(PhysicsSettings newSettings) { settings = newSettings; }
public virtual void setSettings(PhysicsSettings newSettings) { physicsSettings = newSettings; collidables = physicsSettings.collidables; }
// Use this for initialization void Start() { m_instance = this; }
private PhysicsSettings() { m_instance = this; }
/// <summary> /// Simulate physics of objects in room for dT. /// </summary> public static void Run(PhysicsSettings settings, Room room, float dT) { // fetch buffers for the physics job var battleObjectCount = room.AllObjects.Count; var job = new PhysicsJob() { dT = dT, // objects buffer objectCount = battleObjectCount, positions = new NativeArray <float2>(battleObjectCount, Allocator.TempJob), origPositions = new NativeArray <float2>(battleObjectCount, Allocator.TempJob), velocities = new NativeArray <float2>(battleObjectCount, Allocator.TempJob), properties = new NativeArray <ColliderProperties>(battleObjectCount, Allocator.TempJob), // output collision events buffer collisionEvents = new NativeList <int2>(Allocator.TempJob), // load settings into the job PhysicsPassesPerFrame = settings.Passes, BounceAbsorb = settings.BounceAbsorb, VelocityDragConstant = settings.VelocityDragConstant, VelocityDragRelative = pow(settings.VelocityDragRelative, 1f / settings.Passes), // get world boundaries LeftEdge = -room.Width / 2, RightEdge = room.Width / 2, TopEdge = -room.Height / 2, BottomEdge = room.Height / 2, }; // load objects into the buffer var battleObjects = room.AllObjects; for (int i = 0; i < battleObjectCount; i++) { var obj = battleObjects[i]; job.positions[i] = obj.Position; job.velocities[i] = obj.Velocity; job.properties[i] = new ColliderProperties(obj); } // run it! job.Run(); // apply results to the game. Skip NaNs if any. for (int i = 0; i < battleObjectCount; i++) { var newPosition = job.positions[i]; if (any(isnan(newPosition))) { continue; } var newVelocity = job.velocities[i]; if (any(isnan(newVelocity))) { continue; } var obj = battleObjects[i]; if (!obj.Settings.IsStatic) { obj.Position = newPosition; obj.Velocity = newVelocity; } } // dispatch collected collision events foreach (var collisionEvent in job.collisionEvents) { if (collisionEvent.y < 0) { battleObjects[collisionEvent.x].OnCollisionWithWall(); } else { battleObjects[collisionEvent.x].OnCollisionWith(battleObjects[collisionEvent.y]); battleObjects[collisionEvent.y].OnCollisionWith(battleObjects[collisionEvent.x]); } } // return buffer memory job.collisionEvents.Dispose(); job.positions.Dispose(); job.origPositions.Dispose(); job.velocities.Dispose(); job.properties.Dispose(); }