first version
esto y aquello y eso otro
This commit is contained in:
20
New Unity Project/Assets/Scripts/cameraController.cs
Normal file
20
New Unity Project/Assets/Scripts/cameraController.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class cameraController : MonoBehaviour {
|
||||
|
||||
public GameObject player;
|
||||
//so we reference the player on the inspector
|
||||
private Vector3 offset;
|
||||
//so we can calculate distance between player and camera
|
||||
void Start ()
|
||||
{
|
||||
offset = transform.position - player.transform.position;
|
||||
}
|
||||
|
||||
void LateUpdate ()
|
||||
//on lateUpdate because here goes the animation thingies ¿?
|
||||
{
|
||||
transform.position = player.transform.position + offset;
|
||||
}
|
||||
}
|
||||
12
New Unity Project/Assets/Scripts/cameraController.cs.meta
Normal file
12
New Unity Project/Assets/Scripts/cameraController.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68d9a363b9e46f84c97031449bea4bd7
|
||||
timeCreated: 1462651325
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
New Unity Project/Assets/Scripts/playerController.cs
Normal file
24
New Unity Project/Assets/Scripts/playerController.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class playerController : MonoBehaviour {
|
||||
|
||||
public float speed;
|
||||
|
||||
private Rigidbody rb;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
float moveHorizontal = Input.GetAxis ("Horizontal");
|
||||
float moveVertical = Input.GetAxis ("Vertical");
|
||||
|
||||
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
|
||||
|
||||
rb.AddForce (movement * speed);
|
||||
}
|
||||
}
|
||||
12
New Unity Project/Assets/Scripts/playerController.cs.meta
Normal file
12
New Unity Project/Assets/Scripts/playerController.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 839806aa7263f3d4ab4de845712585bd
|
||||
timeCreated: 1462649784
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user