Hi! so i’ve implemented a simple script in my game that allows for a cube to move with WASD and rotate towards the mouse cursor (and attack) Problem is, the cube is 2D so really all i did was make the cube rotate towards the mouse clockwise/counterclockwise, but as soon as i actually use a 2.5D sprite now that sprite just rotates on the wrong axis (rotates clockwise) and not around it self in “3d” space. I’m not sure how i could implement this and i can’t seem to find any help online.
Example

My PlayerController script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerControl : Character
{
[SerializeField]
private HealthStat health;
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Weapon weapon;
private float initHealth = 100;
private float activeMoveSpeed;
public float dashSpeed;
public float dashLength = .5f, dashCooldown = 2f;
private float dashCounter;
private float dashCoolCounter;
Vector2 moveDirection;
Vector2 mousePosition;
protected override void Start()
{
activeMoveSpeed = moveSpeed;
health.Initialize(initHealth, initHealth);
base.Start();
}
// Start is called before the first frame update
// Update is called once per frame
protected override void Update()
{
GetInput();
float moveX = Input.GetAxisRaw("Horizontal");
float moveY = Input.GetAxisRaw("Vertical");
if (Input.GetMouseButtonDown(0))
{
weapon.Fire();
}
moveDirection = new Vector2(moveX, moveY).normalized;
mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetKeyDown(KeyCode.LeftShift))
{
if (dashCoolCounter <= 0 && dashCounter <= 0)
{
activeMoveSpeed = dashSpeed;
dashCounter = dashLength;
}
}
if (dashCounter > 0)
{
dashCounter -= Time.deltaTime;
if (dashCounter <= 0)
{
activeMoveSpeed = moveSpeed;
dashCoolCounter = dashCooldown;
}
}
if (dashCoolCounter > 0)
{
dashCoolCounter -= Time.deltaTime;
}
base.Update();
}
private void GetInput()
{
//debugging
if (Input.GetKeyDown(KeyCode.I))
{
health.MyCurrentValue -= 10;
}
if (Input.GetKeyDown(KeyCode.O))
{
health.MyCurrentValue += 10;
}
}
private void FixedUpdate()
{
rb.velocity = new Vector2(moveDirection.x * activeMoveSpeed, moveDirection.y * activeMoveSpeed);
Vector2 aimDirection = mousePosition - rb.position;
float aimAngle = Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg - 90f;
rb.rotation = aimAngle;
}
}
This is purely a passion project for me and my little brother so help is very much appreciated.