Added 3D player model, added better cam movement
This commit is contained in:
@@ -10,8 +10,8 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
UIHandler uihandler;
|
||||
GameObject interact;
|
||||
public float mouseSpeed = 100; //the sensibility
|
||||
public float controllerSpeed = 0.01f; //the sensibility
|
||||
public float mouseSpeed = 10f; //the sensibility
|
||||
public float controllerSpeed = 1f; //the sensibility
|
||||
float xMaxLimit = 45.0f;
|
||||
float xMinLimit = -45.0f;
|
||||
Vector2 rotation = Vector2.zero;
|
||||
@@ -27,7 +27,7 @@ namespace Assets.Scripts.Player
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.position = new Vector3(transform.parent.transform.position.x, transform.position.y, transform.parent.transform.position.z);
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -50,17 +50,27 @@ namespace Assets.Scripts.Player
|
||||
|
||||
public void lookAround(Vector2 view, bool isController)
|
||||
{
|
||||
rotation.y += view.x;
|
||||
rotation.x += -view.y;
|
||||
rotation.x = Mathf.Clamp(rotation.x, xMinLimit, xMaxLimit);
|
||||
GameObject target = GameObject.Find("targetLooking");
|
||||
if (isController)
|
||||
{
|
||||
transform.eulerAngles = rotation * (controllerSpeed * Time.deltaTime);
|
||||
target.transform.localPosition = target.transform.localPosition + new Vector3(view.x,view.y,0) * controllerSpeed * Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.eulerAngles = rotation * mouseSpeed;
|
||||
//TODO: Look at camera movement -> Not rly smooth. Weird drag
|
||||
target.transform.localPosition = target.transform.localPosition + new Vector3(view.x,view.y,0) * Mathf.Pow(mouseSpeed,2) * 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);
|
||||
}
|
||||
if(target.transform.localPosition.y >= 2){
|
||||
target.transform.localPosition = new Vector3(target.transform.localPosition.x,2f,target.transform.localPosition.z);
|
||||
}
|
||||
if(target.transform.localPosition.y <= -1){
|
||||
target.transform.localPosition = new Vector3(target.transform.localPosition.x,-1f,target.transform.localPosition.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
public class PlayerGameObject : MonoBehaviour
|
||||
{
|
||||
public float speed = 5f;
|
||||
public GameObject[] leftHands;
|
||||
public GameObject[] rightHands;
|
||||
|
||||
UIHandler uihandler;
|
||||
AudioHandler audioHandler;
|
||||
WorldGenerator worldGenerator;
|
||||
@@ -22,10 +26,11 @@ namespace Assets.Scripts.Player
|
||||
int difficulty = 0;
|
||||
bool finishedGame = false;
|
||||
PlayerObject player;
|
||||
public float speed = 5f;
|
||||
DateTime now;
|
||||
int bobbingDirection = -1;
|
||||
|
||||
public bool isArmed;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
@@ -46,12 +51,15 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
|
||||
}
|
||||
generatePlayer();
|
||||
isArmed = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(player == null){
|
||||
return;
|
||||
}
|
||||
if (player.getStat("Killcount").getAmount() == -1)
|
||||
{
|
||||
return;
|
||||
@@ -137,8 +145,11 @@ namespace Assets.Scripts.Player
|
||||
string playername = PlayerPrefs.GetString("playername");
|
||||
difficulty = PlayerPrefs.GetInt("difficulty");
|
||||
player = new PlayerObject(playername, race, role, difficulty);
|
||||
player.getClass().loadHandObjects();
|
||||
GetComponent<Animator>().SetBool("isArmed", true);
|
||||
}
|
||||
|
||||
//Generating player instance for stat preview during creation
|
||||
public void generatePlayer(BasicRace playerRace, BasicClass playerClass, string name, int difficulty)
|
||||
{
|
||||
player = new PlayerObject(name, playerRace, playerClass, difficulty);
|
||||
@@ -164,20 +175,6 @@ namespace Assets.Scripts.Player
|
||||
movement = camera.transform.TransformDirection(movement);
|
||||
movement.y = 0;
|
||||
gameObject.transform.Translate(movement * speed * Time.deltaTime);
|
||||
|
||||
if (input.z != 0)
|
||||
{
|
||||
if (camera.transform.localPosition.y >= 0.5)
|
||||
{
|
||||
bobbingDirection = -1;
|
||||
}
|
||||
else if (camera.transform.localPosition.y <= 0.3)
|
||||
{
|
||||
bobbingDirection = 1;
|
||||
}
|
||||
|
||||
camera.transform.Translate(new Vector3(0, bobbingDirection, 0) * Time.deltaTime / 2);
|
||||
}
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1);
|
||||
}
|
||||
|
||||
@@ -324,6 +321,8 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
player = new PlayerObject();
|
||||
player.loadPlayer(json);
|
||||
player.getClass().loadHandObjects();
|
||||
GetComponent<Animator>().SetBool("isArmed", true);
|
||||
}
|
||||
|
||||
public PlayerObject getPlayer()
|
||||
|
||||
Reference in New Issue
Block a user