added crosshair, worked on controls, fixed locals
This commit is contained in:
@@ -20,6 +20,9 @@ public class Controls : MonoBehaviour
|
||||
PlayerInput playerInput;
|
||||
MoveDirection direction;
|
||||
|
||||
public float mouseSpeed = 10f; //the sensibility
|
||||
public float controllerSpeed = 1f; //the sensibility
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -51,7 +54,14 @@ public class Controls : MonoBehaviour
|
||||
{
|
||||
if (uihandler.canPlayerRotate())
|
||||
{
|
||||
playerCam.GetComponent<PlayerCamera>().lookAround(view, playerInput.currentControlScheme == "Controller");
|
||||
if(playerInput.currentControlScheme == "Controller"){
|
||||
playerCam.GetComponent<PlayerCamera>().lookAround(view, controllerSpeed);
|
||||
player.GetComponent<PlayerGameObject>().rotate(view, controllerSpeed);
|
||||
}
|
||||
else{
|
||||
playerCam.GetComponent<PlayerCamera>().lookAround(view, mouseSpeed);
|
||||
player.GetComponent<PlayerGameObject>().rotate(view, mouseSpeed);
|
||||
}
|
||||
}
|
||||
if (uihandler.canPlayerMove())
|
||||
{
|
||||
|
||||
@@ -85,8 +85,8 @@ namespace Assets.Scripts
|
||||
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
|
||||
saveText = saveText + uihandler.saveLanguage() + "\r\n";
|
||||
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
|
||||
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().mouseSpeed = GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value;
|
||||
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().controllerSpeed = GameObject.Find("slideSensitivityController").GetComponent<Slider>().value;
|
||||
GameObject.Find("Controls").GetComponent<Controls>().mouseSpeed = GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value;
|
||||
GameObject.Find("Controls").GetComponent<Controls>().controllerSpeed = GameObject.Find("slideSensitivityController").GetComponent<Slider>().value;
|
||||
saveText = saveText + "SensitivityMouse:"+GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value + "\r\n";
|
||||
saveText = saveText + "SensitivityController:"+GameObject.Find("slideSensitivityController").GetComponent<Slider>().value;
|
||||
FileHandler.saveOptions(saveText);
|
||||
|
||||
@@ -104,12 +104,12 @@ namespace Assets.Scripts
|
||||
break;
|
||||
case "SensitivityMouse":
|
||||
if(isIngame){
|
||||
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().mouseSpeed = float.Parse(line.Split(':')[1]);
|
||||
GameObject.Find("Controls").GetComponent<Controls>().mouseSpeed = float.Parse(line.Split(':')[1]);
|
||||
}
|
||||
break;
|
||||
case "SensitivityController":
|
||||
if(isIngame){
|
||||
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().controllerSpeed = float.Parse(line.Split(':')[1]);
|
||||
GameObject.Find("Controls").GetComponent<Controls>().controllerSpeed = float.Parse(line.Split(':')[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
UIHandler uihandler;
|
||||
GameObject interact;
|
||||
public float mouseSpeed = 10f; //the sensibility
|
||||
public float controllerSpeed = 1f; //the sensibility
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -45,24 +43,10 @@ namespace Assets.Scripts.Player
|
||||
return null;
|
||||
}
|
||||
|
||||
public void lookAround(Vector2 view, bool isController)
|
||||
public void lookAround(Vector2 view, float speed)
|
||||
{
|
||||
GameObject target = GameObject.Find("targetLooking");
|
||||
if (isController)
|
||||
{
|
||||
target.transform.localPosition = target.transform.localPosition + new Vector3(view.x,view.y,0) * controllerSpeed * Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
target.transform.localPosition = target.transform.localPosition + new Vector3(view.x,view.y,0) * mouseSpeed * Time.deltaTime;
|
||||
}
|
||||
|
||||
if(target.transform.localPosition.x >= 3){
|
||||
target.transform.localPosition = new Vector3(3f,target.transform.localPosition.y,target.transform.localPosition.z);
|
||||
}
|
||||
if(target.transform.localPosition.x <= -3){
|
||||
target.transform.localPosition = new Vector3(-3f,target.transform.localPosition.y,target.transform.localPosition.z);
|
||||
}
|
||||
target.transform.localPosition = target.transform.localPosition + new Vector3(0,view.y,0) * speed * Time.deltaTime;
|
||||
if(target.transform.localPosition.y >= 2){
|
||||
target.transform.localPosition = new Vector3(target.transform.localPosition.x,2f,target.transform.localPosition.z);
|
||||
}
|
||||
@@ -80,7 +64,7 @@ namespace Assets.Scripts.Player
|
||||
if (hit.collider.gameObject.tag.ToLower().Contains("object"))
|
||||
{
|
||||
string obj = hit.collider.gameObject.tag.Split(':')[1];
|
||||
if (hit.distance <= 3 && !obj.ToLower().Equals("house"))
|
||||
if (hit.distance <= 10 && !obj.ToLower().Equals("house"))
|
||||
{
|
||||
if (!uihandler.isPlayerInFight())
|
||||
{
|
||||
|
||||
@@ -10,6 +10,8 @@ using Assets.Scripts.Races;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine.InputSystem;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
namespace Assets.Scripts.Player
|
||||
{
|
||||
@@ -185,6 +187,10 @@ namespace Assets.Scripts.Player
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1);
|
||||
}
|
||||
|
||||
public void rotate(Vector2 input, float speed){
|
||||
transform.Rotate(Vector3.up, input.x * speed * 10 * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void getRotation()
|
||||
{
|
||||
GameObject needle = GameObject.Find("imgNeedle");
|
||||
|
||||
Reference in New Issue
Block a user