testing player character asset
This commit is contained in:
30
Assets/GrigoriyArx/Droll Robots/Scripts/Bullet.cs
Normal file
30
Assets/GrigoriyArx/Droll Robots/Scripts/Bullet.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Bullet : MonoBehaviour
|
||||
{
|
||||
public float lifeTime = 3f;
|
||||
public GameObject HitSplash;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Destroy(gameObject, lifeTime);
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
ContactPoint contact = collision.contacts[0];
|
||||
Quaternion rot = Quaternion.FromToRotation(Vector3.forward, contact.normal); // turn to Normal
|
||||
Vector3 pos = contact.point;
|
||||
|
||||
if (HitSplash != null)
|
||||
{
|
||||
var hitVFX = Instantiate(HitSplash, pos, rot);
|
||||
}
|
||||
|
||||
Destroy(gameObject);
|
||||
Debug.Log("Collision happened");
|
||||
}
|
||||
}
|
||||
18
Assets/GrigoriyArx/Droll Robots/Scripts/Bullet.cs.meta
Normal file
18
Assets/GrigoriyArx/Droll Robots/Scripts/Bullet.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ed7e1cb425e8374ba3e0cbe6ba5c636
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 241268
|
||||
packageName: Droll Robot 02
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/GrigoriyArx/Droll Robots/Scripts/Bullet.cs
|
||||
uploadId: 553932
|
||||
36
Assets/GrigoriyArx/Droll Robots/Scripts/CamHolder.cs
Normal file
36
Assets/GrigoriyArx/Droll Robots/Scripts/CamHolder.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class CamHolder : MonoBehaviour {
|
||||
|
||||
public Transform cam_target;
|
||||
public float smooth = 0.5f;
|
||||
public float rotSpeed = 50f;
|
||||
private Vector3 start_angle;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
start_angle = transform.position;
|
||||
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
if (cam_target != null)
|
||||
{
|
||||
Vector3 desPosition = cam_target.position;
|
||||
Vector3 smoothedPosition = Vector3.Lerp(transform.position, desPosition, smooth*Time.deltaTime);
|
||||
transform.position = smoothedPosition;
|
||||
|
||||
|
||||
if (Input.GetKey ("z"))
|
||||
{
|
||||
transform.Rotate(new Vector3(0,rotSpeed*Time.deltaTime,0));
|
||||
}
|
||||
if (Input.GetKey ("c"))
|
||||
{
|
||||
transform.Rotate(new Vector3(0,rotSpeed*Time.deltaTime*-1,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/GrigoriyArx/Droll Robots/Scripts/CamHolder.cs.meta
Normal file
18
Assets/GrigoriyArx/Droll Robots/Scripts/CamHolder.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 104d04adb2932084d94ce5f039094972
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 241268
|
||||
packageName: Droll Robot 02
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/GrigoriyArx/Droll Robots/Scripts/CamHolder.cs
|
||||
uploadId: 553932
|
||||
15
Assets/GrigoriyArx/Droll Robots/Scripts/HitSplash.cs
Normal file
15
Assets/GrigoriyArx/Droll Robots/Scripts/HitSplash.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HitSplash : MonoBehaviour
|
||||
{
|
||||
public float lifeTime = 1f;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Destroy(gameObject, lifeTime);
|
||||
}
|
||||
|
||||
}
|
||||
18
Assets/GrigoriyArx/Droll Robots/Scripts/HitSplash.cs.meta
Normal file
18
Assets/GrigoriyArx/Droll Robots/Scripts/HitSplash.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f67d30c28c10f545b05d2fb80c3be82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 241268
|
||||
packageName: Droll Robot 02
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/GrigoriyArx/Droll Robots/Scripts/HitSplash.cs
|
||||
uploadId: 553932
|
||||
123
Assets/GrigoriyArx/Droll Robots/Scripts/Rob02Ctrl.cs
Normal file
123
Assets/GrigoriyArx/Droll Robots/Scripts/Rob02Ctrl.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Rob02Ctrl : MonoBehaviour
|
||||
{
|
||||
public float speed = 1.0f;
|
||||
public float battleSpeed = 2f;
|
||||
public Transform bulletSpawnPointLeft;
|
||||
public Transform bulletSpawnPointRight;
|
||||
public GameObject bulletPrefab;
|
||||
public float bulletSpeed = 5;
|
||||
|
||||
|
||||
Animator anim;
|
||||
CharacterController controller;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
controller = GetComponent<CharacterController>();
|
||||
anim.SetFloat("speedMultiplier", speed);
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
anim.SetBool("shoot", false);
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
if (Input.GetAxis("Horizontal") > 0.1f)
|
||||
{
|
||||
anim.SetBool("turnLeft", true);
|
||||
anim.SetBool("turnRight", false);
|
||||
}
|
||||
if (Input.GetAxis("Horizontal") < -0.1f)
|
||||
{
|
||||
anim.SetBool("turnRight", true);
|
||||
anim.SetBool("turnLeft", false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.SetBool("turnLeft", false);
|
||||
anim.SetBool("turnRight", false);
|
||||
|
||||
if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.1f)
|
||||
{
|
||||
anim.SetFloat("Turns", Input.GetAxis("Horizontal"));
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.SetFloat("Turns", 0);
|
||||
}
|
||||
|
||||
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1f)
|
||||
{
|
||||
anim.SetFloat("Speed", Input.GetAxis("Vertical"));
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.SetFloat("Speed", 0);
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown("e"))
|
||||
{
|
||||
anim.SetBool("Packed", !(anim.GetBool("Packed")));
|
||||
if (anim.GetBool("battle"))
|
||||
{
|
||||
anim.SetBool("battle", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown("1"))
|
||||
{
|
||||
anim.SetBool("battle",false);
|
||||
anim.SetFloat("speedMultiplier", speed);
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown("2"))
|
||||
{
|
||||
anim.SetBool("battle", true);
|
||||
anim.SetFloat("speedMultiplier",battleSpeed);
|
||||
}
|
||||
|
||||
if ((Input.GetKeyDown("r"))&&(anim.GetBool("battle")))
|
||||
{
|
||||
anim.SetBool("shoot", true);
|
||||
var bulletL = Instantiate(bulletPrefab, bulletSpawnPointLeft.position, bulletSpawnPointLeft.rotation);
|
||||
bulletL.GetComponent<Rigidbody>().linearVelocity = bulletSpawnPointLeft.forward * bulletSpeed;
|
||||
var bulletR = Instantiate(bulletPrefab, bulletSpawnPointRight.position, bulletSpawnPointRight.rotation);
|
||||
bulletR.GetComponent<Rigidbody>().linearVelocity = bulletSpawnPointRight.forward * bulletSpeed;
|
||||
}
|
||||
|
||||
if ((Input.GetKeyDown("p"))) //death
|
||||
{
|
||||
anim.SetBool("die", true);
|
||||
}
|
||||
if ((Input.GetKeyDown("u"))) //look around
|
||||
{
|
||||
anim.SetBool("look1", true);
|
||||
} else { anim.SetBool("look1", false); }
|
||||
if ((Input.GetKeyDown("y"))) //look at side
|
||||
{
|
||||
anim.SetBool("look2", true);
|
||||
} else { anim.SetBool("look2", false); }
|
||||
if ((Input.GetKeyDown("o"))) //take damage 1
|
||||
{
|
||||
anim.SetBool("hitLeft", true);
|
||||
} else { anim.SetBool("hitLeft", false); }
|
||||
if ((Input.GetKeyDown("i"))) //take damage 2
|
||||
{
|
||||
anim.SetBool("hitRight", true);
|
||||
} else { anim.SetBool("hitRight", false); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
Assets/GrigoriyArx/Droll Robots/Scripts/Rob02Ctrl.cs.meta
Normal file
18
Assets/GrigoriyArx/Droll Robots/Scripts/Rob02Ctrl.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7db760e1b20c81748ad013cb85d2ec2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 241268
|
||||
packageName: Droll Robot 02
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/GrigoriyArx/Droll Robots/Scripts/Rob02Ctrl.cs
|
||||
uploadId: 553932
|
||||
Reference in New Issue
Block a user