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 cyphon · Oct 18, 2012 at 06:21 PM · cameraplayer movementlookat

Top Down Shooter - Look at Cursor with Movement Compensation

Hey guys, I know there are a million posts on how to look at the cursor for TDS style games, but none of the solutions seem to be what I want. I should mention that I am new to Unity, but I am an experienced developer.

My setup is a TDS with perspective. I have the camera placed at the corner of the level and follows the player around. The camera is rotated 25 degrees about the X axis and 45 degrees about the y axis. This gives a look from the corner of the room towards the player and surrounding level. When pressing 'forward' the player moves in a north-east fashion relative to the camera (this is planned).

I need to add the aiming script now, where the player should be facing the cursor at all times.

All solutions that I have tried thus far do accomplish the look at the cursor part (well, sorta), but, are flawed in two ways.

A) They only work on 180 degrees of rotation, anything greater than that they reverse the players rotation.

B) The movement control does not compensate for the rotation, so instead of 'forward' still making the player move northeast relative to the camera, they run towards the cursor.

Ideally, I want the movement controls to keep the player moving in the same direction regardless of the players rotation. Any help would be greatly 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Loius · Oct 18, 2012 at 06:34 PM

Make the character's graphics a child object of "object 2". Only rotate the graphics object, and only move "object 2" - independent movement & rotation.

You can use transform.LookAt to have an object's Z axis face in a certain direction. It's probably worth using that on the player graphics - look at the cursor's position (being sure to zero the Y element of the direction so the player doesn't rotate 'vertically').

Comment
Add comment · Show 2 · 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 cyphon · Oct 18, 2012 at 06:41 PM 0
Share

$$anonymous$$akes sense. I will give it a shot after work. Thanks for the reply

avatar image cyphon · Oct 18, 2012 at 09:08 PM 0
Share

Yep, that worked! Thanks for the help!

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

10 People are following this question.

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

Related Questions

What is difference between local and global coord Vector3. 1 Answer

Having a plane at exactly the far clip of a camera 1 Answer

How to implement lock on with a camera that is not a child of the player object? 1 Answer

Move camera relative to current position 0 Answers

Prevent camera from rolling while looking at object 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