public override void Start() { playerSprite = Entity.Get<SpriteComponent>(); playerController = Entity.Get<CharacterComponent>(); //Please remember that in the GameStudio element the parameter Step Height is extremely important, it not set properly it will cause the entity to snap fast to the ground playerController.JumpSpeed = 5.0f; playerController.Gravity = -10.0f; playerController.FallSpeed = 10.0f; playerController.ProcessCollisions = true; if (!IsLiveReloading) { Script.AddTask(async () => { while (Game.IsRunning) { var collision = await playerController.NewCollision(); // Stop if we collide from side foreach (var contact in collision.Contacts) { if (contact.Normal.X < -0.5f || contact.Normal.X > 0.5f) { movingToTarget = false; break; } } } }); PlayIdle(); } }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); // Will search for an CharacterComponent within the same entity as this script character = Entity.Get<CharacterComponent>(); if (character == null) throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); }
public override void Start() { character = Entity.Get<CharacterComponent>(); character.Gravity = -10.0f; var rigidBodyComponent = Entity.Get<RigidbodyComponent>(); if (rigidBodyComponent != null) { rigidBodyComponent.CanSleep = false; } }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); jumpReactionRemaining = JumpReactionThreshold; // Will search for an CharacterComponent within the same entity as this script character = Entity.Get<CharacterComponent>(); if (character == null) throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); modelChildEntity = Entity.GetChild(0); }
internal void RemoveCharacter(CharacterComponent character) { if (discreteDynamicsWorld == null) { throw new Exception("Cannot perform this action when the physics engine is set to CollisionsOnly"); } var collider = character.NativeCollisionObject; var action = character.KinematicCharacter; discreteDynamicsWorld.RemoveCollisionObject(collider); discreteDynamicsWorld.RemoveCharacter(action); character.Simulation = null; }
internal void AddCharacter(CharacterComponent character, CollisionFilterGroupFlags group, CollisionFilterGroupFlags mask) { if (discreteDynamicsWorld == null) { throw new Exception("Cannot perform this action when the physics engine is set to CollisionsOnly"); } var collider = character.NativeCollisionObject; var action = character.KinematicCharacter; discreteDynamicsWorld.AddCollisionObject(collider, (BulletSharp.CollisionFilterGroups)group, (BulletSharp.CollisionFilterGroups)mask); discreteDynamicsWorld.AddCharacter(action); character.Simulation = this; }
internal void RemoveCharacter(CharacterComponent character) { if (discreteDynamicsWorld == null) throw new Exception("Cannot perform this action when the physics engine is set to CollisionsOnly"); var collider = character.NativeCollisionObject; var action = character.KinematicCharacter; discreteDynamicsWorld.RemoveCollisionObject(collider); discreteDynamicsWorld.RemoveCharacter(action); character.Simulation = null; }
internal void AddCharacter(CharacterComponent character, CollisionFilterGroupFlags group, CollisionFilterGroupFlags mask) { if (discreteDynamicsWorld == null) throw new Exception("Cannot perform this action when the physics engine is set to CollisionsOnly"); var collider = character.NativeCollisionObject; var action = character.KinematicCharacter; discreteDynamicsWorld.AddCollisionObject(collider, (BulletSharp.CollisionFilterGroups)group, (BulletSharp.CollisionFilterGroups)mask); discreteDynamicsWorld.AddCharacter(action); character.Simulation = this; }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); // Get the navigation component on the same entity as this script navigation = Entity.Get<NavigationComponent>(); if (navigation?.NavigationMesh == null) throw new ArgumentException("Please add a NavigationComponent to the entity containing PlayerController with the correct navigation mesh!"); // Will search for an CharacterComponent within the same entity as this script character = Entity.Get<CharacterComponent>(); if (character == null) throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); if (PunchCollision == null) throw new ArgumentException("Please add a RigidbodyComponent as a PunchCollision to the entity containing PlayerController!"); modelChildEntity = Entity.GetChild(0); moveDestination = Entity.Transform.WorldMatrix.TranslationVector; PunchCollision.Enabled = false; }