コード例 #1
0
ファイル: CharacterScript.cs プロジェクト: Aggror/Stride
        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           = new Vector3(0.0f, -10.0f, 0.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();
            }
        }