Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

how to make a rotation with a mouses position???

Discussion in '2D' started by exploding_toaster, Jul 4, 2020.

  1. exploding_toaster

    exploding_toaster

    Joined:
    Jun 5, 2020
    Posts:
    46

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class rotation : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    transform.rotation = Input.mousePosition;

    }
    }


    i want to make my sprite rotate by using the mouse position but this gives me a error help

    the error
    Assets\rotation.cs(16,30): error CS0029: Cannot implicitly convert type 'UnityEngine.Vector3' to 'UnityEngine.Quaternion'
     
  2. Mooxe

    Mooxe

    Joined:
    Sep 18, 2013
    Posts:
    19
    Please watch this video.
     
    exploding_toaster likes this.