fixed compass and jumping

This commit is contained in:
TAASONI3 2024-01-01 18:43:30 +01:00
parent 7eeafdc890
commit dae53866e4
4 changed files with 58 additions and 3357 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,9 +12,6 @@ namespace Assets.Scripts.Player
GameObject interact; GameObject interact;
public float mouseSpeed = 10f; //the sensibility public float mouseSpeed = 10f; //the sensibility
public float controllerSpeed = 1f; //the sensibility public float controllerSpeed = 1f; //the sensibility
float xMaxLimit = 45.0f;
float xMinLimit = -45.0f;
Vector2 rotation = Vector2.zero;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()

View File

@ -27,9 +27,9 @@ namespace Assets.Scripts.Player
bool finishedGame = false; bool finishedGame = false;
PlayerObject player; PlayerObject player;
DateTime now; DateTime now;
int bobbingDirection = -1; int jumpFrameCounter;
public bool isArmed; public bool isArmed;
bool canJump;
private void OnEnable() private void OnEnable()
{ {
@ -52,12 +52,15 @@ namespace Assets.Scripts.Player
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>(); worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
} }
isArmed = true; isArmed = true;
jumpFrameCounter = 0;
canJump = false;
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(player == null){ if (player == null)
{
return; return;
} }
if (player.getStat("Killcount").getAmount() == -1) if (player.getStat("Killcount").getAmount() == -1)
@ -65,7 +68,8 @@ namespace Assets.Scripts.Player
return; return;
} }
if(uihandler.state == UIState.DEATH){ if (uihandler.state == UIState.DEATH)
{
return; return;
} }
@ -157,24 +161,26 @@ namespace Assets.Scripts.Player
public void move(Vector3 input) public void move(Vector3 input)
{ {
GameObject camera = GameObject.Find("Main Camera"); if(gameObject.GetComponent<Rigidbody>().velocity.y <= 0.1f && gameObject.GetComponent<Rigidbody>().velocity.y >= -0.1f){
jumpFrameCounter++;
}
if(jumpFrameCounter >= 10){
canJump = true;
jumpFrameCounter = 0;
}
if (input.y != 0) if (input.y != 0)
{ {
RaycastHit hit; if (canJump)
if (Physics.Raycast(transform.position, -transform.up, out hit, Mathf.Infinity))
{ {
if (hit.distance <= 1.5f) gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, 5, 0);
{ audioHandler.playJump();
gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, 5, 0); canJump = false;
audioHandler.playJump();
}
} }
} }
Vector3 movement = new Vector3(input.x, 0, input.z); Vector3 movement = new Vector3(0, 0, input.z);
movement = camera.transform.TransformDirection(movement);
movement.y = 0;
gameObject.transform.Translate(movement * speed * Time.deltaTime); gameObject.transform.Translate(movement * speed * Time.deltaTime);
gameObject.transform.Rotate(Vector3.up, input.x * 100 * Time.deltaTime);
gameObject.GetComponent<Animator>().SetFloat("velocity", (movement * speed).z); gameObject.GetComponent<Animator>().SetFloat("velocity", (movement * speed).z);
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1); GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1);
} }
@ -182,7 +188,7 @@ namespace Assets.Scripts.Player
public void getRotation() public void getRotation()
{ {
GameObject needle = GameObject.Find("imgNeedle"); GameObject needle = GameObject.Find("imgNeedle");
float rotation = GameObject.Find("Main Camera").transform.rotation.eulerAngles.y; float rotation = -gameObject.transform.rotation.eulerAngles.y;
if (rotation < 0) if (rotation < 0)
{ {
rotation += 360; rotation += 360;
@ -238,7 +244,6 @@ namespace Assets.Scripts.Player
transform.position = new Vector3(transform.position.x + 10, 10, transform.position.z); transform.position = new Vector3(transform.position.x + 10, 10, transform.position.z);
} }
} }
} }
public void displayAction(int index, GameObject image, GameObject desc) public void displayAction(int index, GameObject image, GameObject desc)

View File

@ -45,21 +45,26 @@ public class Tile : MonoBehaviour
int iterations = 0; int iterations = 0;
Vector3 newPoint; Vector3 newPoint;
bool canSpawn; bool canSpawn;
while(list.Count < objectAmount){ while (list.Count < objectAmount)
{
iterations++; iterations++;
canSpawn = true; canSpawn = true;
newPoint = new Vector3(rand.Next(-40, 40) + 100 * position.x, 50, rand.Next(-40, 40) + 100 * position.z); newPoint = new Vector3(rand.Next(-40, 40) + 100 * position.x, 50, rand.Next(-40, 40) + 100 * position.z);
foreach(Vector3 vector in list){ foreach (Vector3 vector in list)
if(Vector3.Distance(vector, newPoint) < 10){ {
if (Vector3.Distance(vector, newPoint) < 10)
{
canSpawn = false; canSpawn = false;
break; break;
} }
} }
if(canSpawn && !list.Contains(newPoint)){ if (canSpawn && !list.Contains(newPoint))
{
list.Add(newPoint); list.Add(newPoint);
iterations = 0; iterations = 0;
} }
if(iterations >= 1000){ if (iterations >= 1000)
{
break; break;
} }
} }