Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 uzzb · Oct 26, 2016 at 10:30 PM · screencharacter movementturnmovescript

How to rotate character respect ScreenView

Hi ! I'm creating a new script for my Controller Character and i found a lot of problems trying to fixed the movements of my object relative the ScreenView.

What i'm trying to do, is a 3D game with only 4 ways to move: W:up, S:down, A:left, D:right

(for now seems pretty easy to do but...)

But what i want, is when i switched my main camera to another position, i want that the character move respecting the view of the screen view, without worried about the position of the camera: alt text

In the 1 camera scenario: if i press "A" the character will turns 90º and will face to the Left (perfect) But in the 2camer scenaro: if i press "A" the character will turns 90º and will face to the top.

I dont know how to do that, no matters where is the player facing, if i press A i want that automatically it faces to the left on the Screen View.

I tryed with:

  • transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime); (fail)

  • Quaternion.LookRotation (fail)

  • Camera.WorldToScreenPoint (fail)

and for the last choice i tryed:

  • if (Input.GetKeyDown(KeyCode.W)) { transform.LookAt(Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height, Camera.main.farClipPlane / 2))); }

The last seems to works but makes a little weird position, it isnt a real 90º or 180º turn left.

any advice or ways to get this?

sin-titulo.png (12.2 kB)
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Workaround for the setresolution bug in unity 2.61 on the Mac? 1 Answer

make a loading screen 1 Answer

Find position of SelectionGrid element clicked 2 Answers

iPhone Screen Size 2 Answers

Keeping a GUI texture from moving during change of screen size 2 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