Character Shooting Mechanic 2D Issues
Hi, sorry the title wasn't very descriptive! I'm having a bit of a mental block with something that I'm trying to do. So, I'm a new programmer and I'm working on a mechanic like a bullet shooter. I want my fire point and the direction of the bullet to change with that of my character. It's important that I mention that this is in 2D and my movement script is as follows:
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Animator animator;
Vector2 movement;
// Update is called once per frame
void Update()
{
//Input
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
animator.SetFloat("Horizontal", movement.x);
animator.SetFloat("Vertical", movement.y);
animator.SetFloat("Speed", movement.sqrMagnitude);
}
void FixedUpdate()
{
//Movement
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime)
}
Ideally, I'd like the firePoint to rotate based on my character's direction, pivoting around the character. Hopefully, this would automatically cause the bullet to be fired in the direction that the character is facing. He has animations for moving Up, Down, Left, and Right, but is able to move in 8 total directions, the ones I mentioned, and the ones in between each.
Thank you so much in advance for the assistance!