Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ScarController : MonoBehaviour
- {
- public float MinDamageMount = 5;
- public float MaxDamageMount = 10;
- public float FireRate = 1f;
- public float ShootDistance = 100;
- float nextRate;
- public Transform Camera;
- public LayerMask mask;
- public PlayerController plr;
- public CharacterController controller;
- public Animator anim;
- public GameObject impactFX;
- void Update()
- {
- RaycastHit hit;
- if (Input.GetKey (KeyCode.Mouse0))
- {
- if (Time.time >= nextRate)
- {
- nextRate = Time.time + 1 / FireRate;
- #if UNITY_EDITOR
- Debug.Log ("DISPARANDO");
- #endif
- if (Physics.Raycast (Camera.transform.position, Camera.transform.forward, out hit, ShootDistance, mask))
- {
- if (hit.collider != null)
- {
- GameObject fx = Instantiate (impactFX);
- fx.transform.position = hit.point;
- Destroy (fx, 3f);
- }
- }
- }
- }
- if (controller.velocity.magnitude != 0)
- {
- anim.SetBool ("Walk", false);
- anim.SetBool ("Walk", true);
- if (plr.isRunning)
- {
- anim.SetBool("Run", false);
- anim.SetBool("Run", true);
- }
- else
- {
- anim.SetBool("Run", true);
- anim.SetBool("Run", false);
- }
- }
- else
- {
- anim.SetBool("Run", true);
- anim.SetBool("Run", false);
- anim.SetBool("Walk", true);
- anim.SetBool("Walk", false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement