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 timo0060 · May 23, 2012 at 07:24 PM · javascriptmouselookat

Object looking straight down when jumping

So my new problem is that when I have my make shift barrel/gun right now looking at the mouse in a 2d world. The barrel and the rest of the gun are a child of an empty gameobject located in the center of the player, and this gameobject is itself a child to the Player. This works perfectly, until I jump. When I jump, the barrel moves up slightly, and then rotates and looks down until you land and move your mouse again. After you move when you hit the ground, it snaps back to looking at the mouse. Here's my LookAt script, very basic:

 function Update () {
    transform.LookAt(PlayerScript.hitPoint);
    transform.Rotate(0,-90,0); 

}

Any help would be greatly appreciated. It's probably an easy fix that I'm just looking over.

EDIT: The LookAt script is attached to the empty GameObject which is a child of the player.

Comment
Add comment · Show 10
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 oliver-jones · May 23, 2012 at 07:44 PM 0
Share

Which child is this script attached to? Is it your root parent?

avatar image timo0060 · May 23, 2012 at 07:46 PM 0
Share

It's attached to the empty game object

avatar image timo0060 · May 24, 2012 at 12:19 AM 0
Share

Anybody please help? It's annoying me cause right at the beginning of the level you fall down and I just want the gun to always look at the mouse cursor no matter what. Any help is most appreciated.

avatar image oliver-jones · May 24, 2012 at 12:21 AM 0
Share

Is this your entire script? Are there more attached to your player?

avatar image timo0060 · May 24, 2012 at 12:25 AM 0
Share

The only part of this that is attached to the player is where I find the mouse potion (hitpoint), but I see no error with that code. This is all of my lookAt code. If you need any code, ask and I'll edit the question to provide you with it.

Show more comments

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.

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

Making character look at mouse 1 Answer

JavaScript: _player.cursor(280) 1 Answer

Mouse Dragging/Throwing Objects with the Mouse Like in Black & White (The Game) 1 Answer

Rotate character to the moving direction problems? 2 Answers

LookAt mouse, with run animation 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