Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Nk.Andrei · Aug 31, 2012 at 07:04 PM · rotationmouseturretytowards

How to make an object rotate on the y axis towards the mouse?

I am new to this and I have tried everything i can come up with but it either dosent work or rotates on a different axis.

function Update () { var pos = transform.position;

var follow = Input.mousePosition; var rotate = Quaternion.LookRotation(follow-transform.position); //transforms vector3 coordonates into quaternion degrees //transform.rotation=Quaternion.Slerp(transform.rotation,rotate, 2.1); //transform.position=Vector3.RotateTowards(transform.position,follow,3.1,1.2); //transform.rotation=Quaternion.FromToRotation(pos,follow);

}

I want to achieve this without using the GetAxis from the input.I want to see if it is possible if not a very simple example would be appreciated.Tried everything from quaternion to vector3.The examples above are the methods that I have tried plus some others but none work the way that I need.Help, explanation and an example would be appreciated.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DenverCoulson · Aug 31, 2012 at 09:19 PM

I think you will need to explain a little better as to what you are trying to do and thenhow you want this to rotate. Input.mousePosition is going to return you a Vector2. A rotation around the y axis is 3 dimensional. You need to convert your Input.mousePosition into a proper 3-dimensional position (aka convert your 2D position on to a specified 3D plane. This is not an actual plane, it would be function you would determine that equates to a plane).

Comment
Add comment · Share
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
0

Answer by Nk.Andrei · Sep 01, 2012 at 01:54 PM

I want to make an object rotate along the y axis towards the mouse position.I want to know if this is possible and if yes then how. Instead of transforming a 2d mouse position into a 3d one I could just make a cube or something follow the mouse pointer. An example and an explanation would be greatly apprciated.Im really stuck here.

Comment
Add comment · Show 1 · Share
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 DenverCoulson · Sep 01, 2012 at 08:28 PM 0
Share

....a cube would be in 3D space so it would do exactly the same thing as converting mouse position into three dimensional coordinates. Draw a picture or something because right now what you want to do makes no sense.

avatar image
0

Answer by Nk.Andrei · Sep 01, 2012 at 01:54 PM

I need the simplest way possible to achieve this.Just rotate an object on the y axis to follow the mouse(rotate towards the mouse on the y axis).I need something simple.

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotate and Move towards Mouse Point 0 Answers

3D Turret Rotation 0 Answers

Freeze Camera Rotation that is attached to the object in certain moments 0 Answers

TurretRotation on a starship (full 3d) 3 Answers

2d turret problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges