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 N1warhead · Jan 06, 2015 at 05:41 PM · guicanvasspawning

Canvas & Player spawning

Hey guys, I'm working on a multiplayer game, I have everything working.

But the Canvas is weird to work with..

I have each player spawn with a Canvas, etc. Well, When I spawn the player, he has to be at rotation of 0, but what if I want to spawn the player at a different angle. I mean nobody always wants to spawn in the same direction no matter what team you are.

Is there any way to spawn player and have the canvas rotate to the direction the play spawns?

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
1

Answer by TonyLi · Jan 06, 2015 at 05:49 PM

If it's a world-space canvas childed to the player GameObject, it should automatically match rotation. Otherwise add a script like this:

 using UnityEngine;

 public class MatchRotation : MonoBehaviour {
 
     public Transform player;
     public Transform canvas;
 
     void OnStart() {
         canvas.rotation = player.rotation;
     }
 }

You'll need to assign player and canvas. Or put it on one of the GameObjects and use that GameObject's transform in place of player or canvas.

Comment
Add comment · Show 6 · 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 N1warhead · Jan 06, 2015 at 05:51 PM 0
Share

Thank you, I'm going to try it really quick!

avatar image N1warhead · Jan 06, 2015 at 06:05 PM 0
Share

I see it work for like a split second, then it just disappears :(.

I guess it goes back to where it was before.

avatar image N1warhead · Jan 06, 2015 at 06:15 PM 0
Share

I got it, I had to add it in the Update function.... Wish I didn't have to do it that way.

Unless there is another way?

avatar image TonyLi · Jan 06, 2015 at 06:19 PM 0
Share

I depends on what you need it to do. Can you make the canvas a child of the player GameObject? Then you don't need to use any scripts.

Otherwise, if the player can rotate during gameplay and you want the canvas to rotate along with it, you'll need to use Update().

avatar image N1warhead · Jan 06, 2015 at 06:22 PM 0
Share

I tried making it a child that's how I was doing it before... It would only work if I spawned in the direction that the Canvas was originally placed.

I guess I'll do it in the Update Function. I mean it's just one single line, it shouldn't cause a lot of overhead with 30 players.

But I'll mark Answer as correct, as it is correct.

Thank you so much for your help! Can't believe I didn't think about it! lol.

Show more comments

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

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

Related Questions

Multiple Cars not working 1 Answer

4.6 UI Canvas is smaller than normal 1 Answer

Random spawning papers, plus GUI texture book help. 0 Answers

Display Bullets Left on Screen 1 Answer

Not working gui buttons 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