added coments to scrtipts
This commit is contained in:
parent
249b6909c7
commit
7b97be4e9a
2 changed files with 7 additions and 2 deletions
|
|
@ -250,6 +250,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: ec5d582fdf544e84d8dff955464dd912, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
moveSpeed: 1
|
||||
--- !u!1 &705507993
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ public class Dobber : MonoBehaviour
|
|||
|
||||
void Awake()
|
||||
{
|
||||
//i don't know why dose need to reference it's self but it's requiered to work
|
||||
playerControls = new PlayerControls();
|
||||
//automatically find rigidbody in character
|
||||
rb = gameObject.GetComponent<Rigidbody>();
|
||||
//lock rotation or the rigidbody
|
||||
//lock rotation of the rigidbody
|
||||
rb.constraints = RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX;
|
||||
//here we enable controlls for Dobber character
|
||||
playerControls.DobberControls.Enable();
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +37,7 @@ public class Dobber : MonoBehaviour
|
|||
//this void assignes values to input virables
|
||||
void Inputs()
|
||||
{
|
||||
//reading the Vector2 value and assigning it to moveHorizontal and moveVertical
|
||||
moveHorizontal = playerControls.DobberControls.Walk.ReadValue<Vector2>().x;
|
||||
moveVertical = playerControls.DobberControls.Walk.ReadValue<Vector2>().y;
|
||||
|
||||
|
|
@ -42,8 +45,9 @@ public class Dobber : MonoBehaviour
|
|||
|
||||
void Move()
|
||||
{
|
||||
|
||||
//new Vector3 for calculating movement values
|
||||
Vector3 move = new Vector3(moveHorizontal * 100 * moveSpeed * Time.deltaTime, rb.velocity.y, moveVertical * 100 * moveSpeed * Time.deltaTime);
|
||||
//here we apply the movement related to the rotation of player
|
||||
rb.velocity = transform.right * move.x + transform.up * move.y + transform.forward * move.z;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue