• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MonkeyAssassin8 · Jun 19, 2011 at 02:42 AM · cameraforwardmain

Lock Cursor and Camera.main.transform.forward are different

I'm making an fps that shows the enemy's health above their head, and for the health to appear, the mouse must be over the object, but the direction of the bullet (camera's forward direction) does not match that of mouse position that the Lock Cursor put it. Any idea why this is happening?

ps. I shouldn't need to post code, as I've checked my center align and there's nothing wrong with any of the code.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image aldonaletto · Jun 19, 2011 at 03:13 AM 1
Share

If you're locking the cursor, how do you show the mouse position? There's some crosshair or the like following the mouse movement?

avatar image Bunny83 · Jun 19, 2011 at 03:36 AM 3
Share
  • LockCursor will hide and lock the mouse cursor in the center of the screen.

  • the mouse position is a 2d coordinate on the screen.

  • Camera.main.transform.forward is just a direction in 3d space

That are 3 totally different things... i really don't get your question. Your code would maybe explain what you want to do. If you want to edit your question only include relevant parts of your code and highlight it with the "101 010" button.

avatar image MonkeyAssassin8 · Jun 19, 2011 at 06:10 AM 0
Share

What I've done is set the screen to something basic (800x600) and put a GUITexture on half of the screen. This matches up with the cursor, but when I unlock the mouse, I find that it appears above the cursor by about 50 pixels.

avatar image MonkeyAssassin8 · Aug 02, 2011 at 05:25 AM 0
Share

when you press escape, the mouse is unlocked and is shown.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to set main camera? 3 Answers

Camera moving itself, still following an object 1 Answer

object collision attatched to camera 1 Answer

Camera.main.WorldToViewportPoint & GuiTexture 2 Answers

How can I have the camera forward in a vertex shader? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges