Exemplo n.º 1
0
        public void addToPosition(Vector3 vectorToAdd, float amount)
        {
            Vector3 rotatedVector = Vector3.Transform(vectorToAdd, camera.rotation);
            Vector3 planeMove     = new Vector3(rotatedVector.X, 0, rotatedVector.Z);

            if (planeMove != Vector3.Zero)
            {
                planeMove.Normalize();
            }

            Vector3 oldPos     = new Vector3(position.X, position.Y, position.Z);
            Vector3 moveVector = moveSpeed * planeMove * amount;

            position += moveVector;
            checkPos(); //Fixar så man kan kolla heightmap utan krash

            //Fixar så man inte är under banan
            if (position.Y < Globals.level.heightData[(int)Math.Abs(position.X), (int)Math.Abs(position.Z)])
            {
                position.Y = Globals.level.heightData[(int)Math.Abs(position.X), (int)Math.Abs(position.Z)];
            }

            //Fixa så man inte kan gå upp för allt för branta objekt
            if (oldPos != Vector3.Zero && //fulfix så man inte fastnar när man startar
                position.Y - oldPos.Y > 4.5f)
            {
                position = oldPos;
            }


            handleJump(amount);

            //position += moveSpeed * rotatedVector * amount * 3; //NOclip läge kommentera koden över

            camera.position = getCameraPos();
            camera.updateViewMatrix();
        }