Question by
JokingJoker25 · Jul 29, 2020 at 10:17 AM ·
rotationrotate objectrotatearound
How I can i rotate a bullet after spawning relative to the mouseposition?
I have this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveToMouseCursor120°:MonoBehaviour
{
private Rigidbody2D rb;
private Vector2 mousePosition;
private Vector2 direction;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
direction = (mousePosition - (Vector2)transform.position);
}
private void FixedUpdate()
{
rb.velocity = (direction.normalized * Stats.BulletSpeed);
}
}
How can i now turn the bullet 120° relative to the mouse Position.
Comment
Your answer
Follow this Question
Related Questions
How to rotate an object around a player when pushing a button..? 0 Answers
Make GameObject rotate around another around random axis but with fixed distance 0 Answers
constant rotation using keypress 0 Answers
Gameobject wont move after rotating it 0 Answers
How to find current vertical axis 1 Answer