Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: AimPlayer
- // Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: A258C9B1-E700-457A-BAE7-06EFF4747DB4
- // Assembly location: /Volumes/T5_1TB/Projects/WakeApp/23_Petr/build/TestWakeApp_Data/Managed/Assembly-CSharp.dll
- using UnityEngine;
- public class AimPlayer : MonoBehaviour
- {
- public float power = 1f;
- public float rayDistance = 1f;
- public GameObject Gun;
- public Transform player;
- public int fireRange;
- public Transform enemy;
- public float speedRotation;
- public float speeedMove;
- public GameObject bulletPref;
- public Transform muzzle;
- public GameObject bullet;
- private bool IsReadyToFire
- {
- get
- {
- return (double) Vector3.Distance(this.transform.position, this.player.transform.position) <= (double) this.fireRange;
- }
- }
- private void Start()
- {
- }
- private void AiBot()
- {
- this.enemy.rotation = Quaternion.Slerp(this.enemy.rotation, Quaternion.LookRotation(this.player.position - this.enemy.position), this.speedRotation * Time.deltaTime);
- if (this.IsReadyToFire)
- {
- Ray ray = new Ray(this.transform.position, this.transform.forward);
- RaycastHit hitInfo;
- Physics.Raycast(ray, out hitInfo, (float) this.fireRange);
- Debug.DrawRay(ray.origin, ray.direction * (float) this.fireRange, Color.blue);
- if (!((Object) hitInfo.collider != (Object) null) || !hitInfo.collider.CompareTag("Mob"))
- return;
- this.bullet = Object.Instantiate<GameObject>(this.bulletPref, this.muzzle.position, this.muzzle.rotation);
- this.bullet.GetComponent<Rigidbody>().AddForce(this.bullet.transform.forward * this.power, ForceMode.Impulse);
- Object.Destroy((Object) this.bullet, 2f);
- }
- else
- this.enemy.transform.position += this.enemy.forward * this.speeedMove * Time.deltaTime;
- }
- private void Update()
- {
- this.AiBot();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement