Mouse implementation 1
This commit is contained in:
parent
7bc8fffdd0
commit
a0312d35ca
3 changed files with 38 additions and 2 deletions
|
@ -299,6 +299,11 @@ Prefab:
|
|||
propertyPath: m_Name
|
||||
value: NPC (3)
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 54771552521138126, guid: b25e969032ebb1f4089308db11ee93b1,
|
||||
type: 2}
|
||||
propertyPath: m_IsKinematic
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: b25e969032ebb1f4089308db11ee93b1, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
|
@ -399,7 +404,7 @@ Rigidbody:
|
|||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Interpolate: 1
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &966385057
|
||||
|
@ -413,6 +418,8 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 3c9e5b8e36b3b0747811ece9fa00437a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
particle: {fileID: 1057615597006810, guid: b25e969032ebb1f4089308db11ee93b1, type: 2}
|
||||
TransitionSpeed: 1
|
||||
--- !u!4 &984138133 stripped
|
||||
Transform:
|
||||
m_PrefabParentObject: {fileID: 4550573785341638, guid: b25e969032ebb1f4089308db11ee93b1,
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
public GameObject particle;
|
||||
public float TransitionSpeed;
|
||||
private Rigidbody rigi;
|
||||
private Vector3 velocity = Vector3.zero;
|
||||
|
||||
void Start()
|
||||
{
|
||||
rigi = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
|
||||
|
@ -9,5 +20,23 @@ public class PlayerController : MonoBehaviour
|
|||
|
||||
transform.Rotate(0, x, 0);
|
||||
transform.Translate(0, 0, z);
|
||||
|
||||
RaycastHit hit;
|
||||
if (Input.GetButtonDown("Fire1")) {
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out hit)) {
|
||||
Vector3 wantedPos = hit.point;
|
||||
wantedPos.y = 0.5f;
|
||||
Instantiate (particle, wantedPos, transform.rotation);
|
||||
}
|
||||
}
|
||||
if (Input.GetButtonDown("Fire2")) {
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out hit)) {
|
||||
Vector3 wantedPos = hit.point;
|
||||
wantedPos.y = 0.5f;
|
||||
transform.position = Vector3.Lerp (transform.position, wantedPos, Time.deltaTime * TransitionSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ public class SimpleNPCBehavior : MonoBehaviour
|
|||
|
||||
void Start()
|
||||
{
|
||||
target.Set(0.0f, 0.5f, 0.0f);
|
||||
target.Set (4.0f - (8.0f * Random.value), 0.5f, 4.0f - (8.0f * Random.value));
|
||||
rigi = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue