Browse Source

Fixed player prefab

master
JoshuaReason 5 years ago
parent
commit
0e444529b3
5 changed files with 23 additions and 7 deletions
  1. +6
    -2
      Assets/Prefabs/RealLocalPlayer.prefab
  2. +4
    -1
      Assets/Prefabs/RealRemotePlayer.prefab
  3. +4
    -0
      Assets/Scipts/Map.cs
  4. +3
    -2
      Assets/Scipts/PlayerControllers/Player.cs
  5. +6
    -2
      Assets/Scipts/PlayerControllers/RemotePlayer.cs

+ 6
- 2
Assets/Prefabs/RealLocalPlayer.prefab View File

@ -768,7 +768,7 @@ Transform:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1706194438886280} m_GameObject: {fileID: 1706194438886280}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: 0.7693971, z: -0, w: 0.6387708}
m_LocalPosition: {x: 0, y: 0.53, z: 0} m_LocalPosition: {x: 0, y: 0.53, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
@ -1204,10 +1204,14 @@ MonoBehaviour:
Name: Name:
Image: {fileID: 0} Image: {fileID: 0}
playerModel: {fileID: 1706194438886280} playerModel: {fileID: 1706194438886280}
scale: 0.1
playerAnim: {fileID: 0}
dummieAnims: []
scale: 1
charControl: {fileID: 143426586791887808} charControl: {fileID: 143426586791887808}
Animator: {fileID: 95357577853386682} Animator: {fileID: 95357577853386682}
Speed: 5 Speed: 5
recipe: {fileID: 0}
WalkingSounds: {fileID: 0}
--- !u!114 &114874876091907484 --- !u!114 &114874876091907484
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

+ 4
- 1
Assets/Prefabs/RealRemotePlayer.prefab View File

@ -1039,8 +1039,11 @@ MonoBehaviour:
Name: Name:
Image: {fileID: 0} Image: {fileID: 0}
playerModel: {fileID: 1067210703148028} playerModel: {fileID: 1067210703148028}
scale: 0.1
playerAnim: {fileID: 95748578200216180}
dummieAnims: []
scale: 1
Animator: {fileID: 95748578200216180} Animator: {fileID: 95748578200216180}
PlayerModel: {fileID: 1067210703148028}
--- !u!136 &136963308744459646 --- !u!136 &136963308744459646
CapsuleCollider: CapsuleCollider:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

+ 4
- 0
Assets/Scipts/Map.cs View File

@ -33,6 +33,10 @@ public class Map : MonoBehaviour
GenerateTiles(); GenerateTiles();
CreateDummys(); CreateDummys();
Random.State state = Random.state;
Random.InitState((int)System.DateTime.Now.Ticks);
LocalPlayer.transform.position = new Vector3(Random.Range(minX, maxX), 5, Random.Range(minX, maxX));
Random.state = state;
} }
//Create dummy players for the world wrapping //Create dummy players for the world wrapping

+ 3
- 2
Assets/Scipts/PlayerControllers/Player.cs View File

@ -9,8 +9,8 @@ public class Player : MonoBehaviour
public GameObject playerModel; public GameObject playerModel;
protected Map map; protected Map map;
private Animator playerAnim;
private List<Animator> dummieAnims = new List<Animator>();
public Animator playerAnim;
public List<Animator> dummieAnims = new List<Animator>();
public float scale = 0.1f; public float scale = 0.1f;
@ -61,6 +61,7 @@ public class Player : MonoBehaviour
foreach (GameObject dummie in dummies) foreach (GameObject dummie in dummies)
{ {
dummie.transform.rotation = playerModel.transform.rotation; dummie.transform.rotation = playerModel.transform.rotation;
dummieAnims[count].SetFloat("WalkSpeed", playerAnim.GetFloat("WalkSpeed")); dummieAnims[count].SetFloat("WalkSpeed", playerAnim.GetFloat("WalkSpeed"));
if (playerAnim.GetBool("PickUp")) if (playerAnim.GetBool("PickUp"))

+ 6
- 2
Assets/Scipts/PlayerControllers/RemotePlayer.cs View File

@ -5,6 +5,7 @@ using UnityEngine;
public class RemotePlayer : Player { public class RemotePlayer : Player {
public Animator Animator; public Animator Animator;
public GameObject PlayerModel;
private float walkSpeed; private float walkSpeed;
private Vector3 lastPosition; private Vector3 lastPosition;
@ -23,9 +24,12 @@ public class RemotePlayer : Player {
private void DoAnimation() private void DoAnimation()
{ {
Vector3 dir = lastPosition - transform.position;
Vector3 dir = transform.position - lastPosition;
lastPosition = transform.position; lastPosition = transform.position;
Animator.SetFloat("WalkSpeed", dir.magnitude); Animator.SetFloat("WalkSpeed", dir.magnitude);
transform.forward = dir.normalized;
Debug.Log(dir.normalized);
PlayerModel.transform.LookAt(PlayerModel.transform.position + dir, Vector3.up);
//PlayerModel.transform.forward = dir.normalized;
} }
} }

Loading…
Cancel
Save