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 coxy17 · Nov 25, 2013 at 11:45 AM · lookatrotatetowards

Look at object when entering a trigger

Hi, I am trying to get my player to rotate and look at the trigger (box) when entering the trigger.

Setup 1. Player 2. trigger

What happens 1. Player approaches trigger (just a box) and is e.g. 90 degrees forward from the player position. 2. Player smooth rotates and positions itself to look at the trigger (rotates 90 degrees).

Problem I have tried getting the triggers velocity and applying a smooth look at but it always looks at the triggers Z axis. This causes problems when re-entering the same trigger from another angle e.g. opposite side, as this causes the player to flip around e.g. 180 degrees?

Anyway im pretty much lost on what to do now. Hope this makes sense.

Example diagram Diagram showing what im trying to achieve

Any advice would be appreciated

Nick

rotate towards.jpg (84.7 kB)
Comment
Add comment · Show 2
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 coxy17 · Nov 29, 2013 at 03:22 PM 0
Share

Hi, Ill try and explain a little further as im not an expert in Unity so here it goes.

Ive attached another diagram to show you what i mean, i want the player to be able to enter (at any angle) into the 'trigger' and the player doesnt look in the same direction (Z) of the trigger, but just X. So the player finds 'Up Vector'. This would allow the player only to align on X. But its a 3D game so i realise this will make it alot more complex.

Any ideas? sorry if your answer is the way but i just wanted to be clear before trying.

example of 180 degree return

Thanks for your time

Nick

another example.jpg (143.9 kB)
avatar image ABerlemont · Nov 29, 2013 at 03:29 PM 0
Share

One of the two player at the top can't exist. The X axis as to be on the other side of the ZY axis on one of the two.

$$anonymous$$y answer is wrong then. I thought the player would always look at the trigger's direction. But if it will turn based on the side he entered through it's way more complicated :)

I'll update my answer to something maybe more suited for you.

1 Reply

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

Answer by ABerlemont · Nov 25, 2013 at 02:38 PM

If you are trying to make your player look at the same direction as the trigger you should use in an Update()

Quaternion.RotateTowards(player.transform.rotation, trigger.transform.rotation, Time.deltaTime * lookAtSpeed);

It should take the shorter path in every situation.

Hope that helps

EDIT

You should cut your trigger in different little triggers. Each trigger will give a direction to the player when the player collide with it.

alt text

When the player will colide with A it will take the orientation of A (blue arrow) When the player will colide with B it will take the orientation of B ...

Would that work ?

EDIT typos


untitled-1.jpg (20.6 kB)
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 coxy17 · Dec 02, 2013 at 08:32 AM 0
Share

Thanks sooooo much! you helped me alot!

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

17 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Smooth LookAt OnTriggerEnter for static enemies 1 Answer

Rotating object towards transform array 2 Answers

How to use Look-at using only 2 axis to rotate. 0 Answers

Rotate slowly to target position? 3 Answers

Rotating Game Object in Movement Direction on planet with Faux Gravity Unity 3D 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