fixed compass and jumping
This commit is contained in:
parent
7eeafdc890
commit
dae53866e4
File diff suppressed because it is too large
Load Diff
@ -12,9 +12,6 @@ namespace Assets.Scripts.Player
|
||||
GameObject interact;
|
||||
public float mouseSpeed = 10f; //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
|
||||
void Start()
|
||||
|
||||
@ -27,9 +27,9 @@ namespace Assets.Scripts.Player
|
||||
bool finishedGame = false;
|
||||
PlayerObject player;
|
||||
DateTime now;
|
||||
int bobbingDirection = -1;
|
||||
|
||||
int jumpFrameCounter;
|
||||
public bool isArmed;
|
||||
bool canJump;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@ -52,12 +52,15 @@ namespace Assets.Scripts.Player
|
||||
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
|
||||
}
|
||||
isArmed = true;
|
||||
jumpFrameCounter = 0;
|
||||
canJump = false;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(player == null){
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getStat("Killcount").getAmount() == -1)
|
||||
@ -65,7 +68,8 @@ namespace Assets.Scripts.Player
|
||||
return;
|
||||
}
|
||||
|
||||
if(uihandler.state == UIState.DEATH){
|
||||
if (uihandler.state == UIState.DEATH)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -157,24 +161,26 @@ namespace Assets.Scripts.Player
|
||||
|
||||
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)
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(transform.position, -transform.up, out hit, Mathf.Infinity))
|
||||
if (canJump)
|
||||
{
|
||||
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);
|
||||
audioHandler.playJump();
|
||||
canJump = false;
|
||||
}
|
||||
}
|
||||
Vector3 movement = new Vector3(input.x, 0, input.z);
|
||||
movement = camera.transform.TransformDirection(movement);
|
||||
movement.y = 0;
|
||||
Vector3 movement = new Vector3(0, 0, input.z);
|
||||
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.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1);
|
||||
}
|
||||
@ -182,7 +188,7 @@ namespace Assets.Scripts.Player
|
||||
public void getRotation()
|
||||
{
|
||||
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)
|
||||
{
|
||||
rotation += 360;
|
||||
@ -238,7 +244,6 @@ namespace Assets.Scripts.Player
|
||||
transform.position = new Vector3(transform.position.x + 10, 10, transform.position.z);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void displayAction(int index, GameObject image, GameObject desc)
|
||||
|
||||
@ -45,21 +45,26 @@ public class Tile : MonoBehaviour
|
||||
int iterations = 0;
|
||||
Vector3 newPoint;
|
||||
bool canSpawn;
|
||||
while(list.Count < objectAmount){
|
||||
while (list.Count < objectAmount)
|
||||
{
|
||||
iterations++;
|
||||
canSpawn = true;
|
||||
newPoint = new Vector3(rand.Next(-40, 40) + 100 * position.x, 50, rand.Next(-40, 40) + 100 * position.z);
|
||||
foreach(Vector3 vector in list){
|
||||
if(Vector3.Distance(vector, newPoint) < 10){
|
||||
foreach (Vector3 vector in list)
|
||||
{
|
||||
if (Vector3.Distance(vector, newPoint) < 10)
|
||||
{
|
||||
canSpawn = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(canSpawn && !list.Contains(newPoint)){
|
||||
if (canSpawn && !list.Contains(newPoint))
|
||||
{
|
||||
list.Add(newPoint);
|
||||
iterations = 0;
|
||||
}
|
||||
if(iterations >= 1000){
|
||||
if (iterations >= 1000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user