Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Transform target;
- public clickme _active;
- public float degrees, distance;
- public GameObject ebullet;
- public Transform Bullet_position;
- // Update is called once per frame
- void Update()
- {
- target = _active.aiming_point;
- distance = Vector3.Distance(target.position, transform.position);
- if (target != null)
- {
- degrees = Vector3.Angle(target.position - transform.position, transform.forward);
- }
- else
- {
- }
- if (_active.actives == false)
- {
- if (degrees <= 50 && target != null)
- {
- Quaternion rotation = Quaternion.LookRotation(target.position - transform.position);
- transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 3.0f);
- if (degrees <= 10)
- {
- GameObject bullets = Instantiate(ebullet) as GameObject;
- bullets.transform.position = Bullet_position.transform.position * 1;
- Rigidbody rb = bullets.GetComponent<Rigidbody>();
- rb.velocity = transform.forward * 20;
- Destroy(bullets, 4f);
- }
- }
- }
- else
- {
- Quaternion rotation = Quaternion.LookRotation(transform.forward);
- transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 1.0f);
- }
- } // end update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement