How to make object point at mouse?

First day on the internet?

Stuff can BE wrong. Stuff can BECOME wrong.

Maybe you’re just looking at the wrong stuff!

Maybe you just mis-read and/or mis-typed stuff.

Maybe you chose Bing as your search engine.

These are all things. I have seen them all. Get used to them.

A way to find the solution:

You may be able to simply drive transform.forward (or transform.up when in 2D) equal to your movement vector.

Otherwise, use Mathf.Atan2() to derive heading from cartesian coordinates:

https://discussions.unity.com/t/769743/4

Sine/Cosine/Atan2 (sin/cos/atan2) and rotational familiarity and conventions

https://discussions.unity.com/t/863372/8

The general form for reporting technical issues to total strangers is this:

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

Do not TALK about code without posting it. Do NOT retype code. Copy/paste and post code properly. ONLY post the relevant code, and then refer to it in your discussion. Do NOT post photographs of code.

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379