unskilledd
unskilledd
CC#
Created by unskilledd on 2/3/2023 in #help
❔ Make a sprite follow mouse while pivoting around character in Unity
Hi, I its hard to describe my issue by describing it since im not sure exactly what I'm looking for but basically I have a rigid body and a gun. I made it so the gun moves around the rigid body player. I followed this tutorial https://www.youtube.com/watch?v=LqrAbEaDQzc for the gun system. The problem is it also spins the player towards the mouse aswell since it was designed like that in the tutorial. That's not what I want for my game. I want to move the gun around the player, and not have the player move with the gun. I know that there is an issue with the bullets aswell, but I'm going to fix that after I fix the aiming system. Here is a video of what is happening and my code. Thanks a lot! Player Movement.cs and GunScript.cs attached as 2 txt files since its too Bullet.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet : MonoBehaviour
{
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Enemy")
{
Destroy(collision.gameObject);
Destroy(gameObject);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet : MonoBehaviour
{
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Enemy")
{
Destroy(collision.gameObject);
Destroy(gameObject);
}
}
}
2 replies