![Polarjad](/assets/img/avatar_default.png)
Added sprites for main character, idle and walking animations and scripts, gun rotation, enemies sprites and walk animation.
16 lines
456 B
C#
16 lines
456 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class GunRotation : MonoBehaviour
|
|
{
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
|
|
difference.Normalize();
|
|
float rotationZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
|
|
transform.rotation = Quaternion.Euler(0f, 0f, rotationZ);
|
|
}
|
|
}
|