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
-2
Question by Karl Kujak · Jul 08, 2010 at 09:11 PM · closed

object to point at mouse based on mouse position

I need the object to aim at the mouse. Like a side Scrolling shooter would. right now it "Moves"....but not really where the mouse is. This is what i have for code.

var speed : float = 1.0; //how fast the object should rotate

function Update(){ transform.Rotate(Vector3(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0) Time.deltaTime speed); }

that is on my gun object. I think i need to also change the rotate point on my gun any idea on how i would do that?

thanks alot Karl

Comment
Add comment · Show 8
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 Karl Kujak · Jul 08, 2010 at 09:29 PM 0
Share

http://www.youtube.com/watch?v=2lpZLcELFTI Here is a video to what is happening. Please HELP!!

avatar image Cyclops · Jul 09, 2010 at 12:33 AM 0
Share

yet another duplicate question: http://answers.unity3d.com/questions/14792/gun-object-following-mouse

avatar image Cyclops · Jul 09, 2010 at 12:35 AM 1
Share

@$$anonymous$$arl, please stop repeating the same Question. Take @SpikeX's advice, and learn Unity. If you don't want to bother even doing a tutorial, why should we bother to write your code for you?

avatar image Karl Kujak · Jul 09, 2010 at 01:00 AM 0
Share

well i thought this was UnityAnswers not unity we will give you links for tuts.com

avatar image Cyclops · Jul 09, 2010 at 01:04 AM 0
Share

@$$anonymous$$arl, @SpikeX gave you an answer - Transform.LookAt() will do what you want.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by qJake · Jul 08, 2010 at 10:14 PM

I think you're looking for Transform.LookAt(). You call this on the object that you want to rotate, and you give it a Vector3 point in 3D space where you want the object to rotate to.

Comment
Add comment · Show 3 · 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 Karl Kujak · Jul 08, 2010 at 10:16 PM 0
Share

Do you have the code i need to use. Im really new at this.

avatar image qJake · Jul 08, 2010 at 10:19 PM 3
Share

If you're new, take the time to learn. Unity isn't a toy, it's a professional game development tool, and if you expect to learn it overnight, you are sorely mistaken. I'm not going to give you working code, you need to figure it out on your own, that's how you learn. See this question for a list of tutorials: http://answers.unity3d.com/questions/4897/how-can-i-start-learning-unity-fast-list-of-tutorials

avatar image Karl Kujak · Jul 08, 2010 at 10:23 PM 0
Share

im an artist, im trying to put together a game i have everything in my game working accept this. I really dont feel like going threw a whole tut.

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

No one has followed this question yet.

Related Questions

How do you make your main Character jump into a car 1 Answer

I am trying to Randomize my Answers? 1 Answer

circular progress bar 1 Answer

Game stuck and crash while playing 0 Answers

How to keep my character from falling through the floor? 0 Answers


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