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 /
This question was closed Sep 26, 2017 at 01:28 AM by srhunity for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by srhunity · Sep 26, 2017 at 12:04 AM · 3d2d sprites

Have a billboardsprite face camera while keeping collider grounded

Hi everybody. I'm new to developing and programming in Unity and I believe I've finally come to a roadblock I need help with. Here is the basic gist of my scenario:

I'm developing a game where the environment is 3D but the player and the enemies are sprites. Both the 3D and 2D assets are viewed through an orthographic camera that follows the player sprite whenever it moves and the player can rotate the camera around the player within a set radius, so I need to make the player sprite into a billboard sprite so that the sprite always faces the camera no matter how the camera is rotated around it. I've already created the script needed to do this, which is as follows:

     public Transform MyCameraTransform;
     private Transform MyTransform;
     public bool alignNotLook = true;
 
     // Use this for initialization
     void Start()
     {
         MyTransform = this.transform;
         MyCameraTransform = Camera.main.transform;
     }
 
     // Update is called once per frame
     void LateUpdate()
     {
         if (alignNotLook)
             MyTransform.forward = MyCameraTransform.forward;
         else
             MyTransform.LookAt(MyCameraTransform, Vector3.up);
     }
 }

This is the script needed to make the sprite face the camera always. However, because of the way ".Lookat" behaves, the entire transform of the player object faces the camera and not just the sprite. This means that the box collider I have attached to my player object faces the camera as well, which causes the object's physics to act strange, ie the object moves up and off of the environment instead of just staying and moving on it. I have attached two pictures to show the behavioralt text: alt text

I have researched to see if there is a way to have just the sprite image face the camera and not the whole transform of the object face it, but I can't seem to find anything on this particular scenario. I have tried to mess with the box collider on the object and have even changed it to capsule and sphere colliders to see if it would help with the problem at all, but no luck. I'm at a lost as to what I should do now. Is there a way to change the script to make it so that only the image is facing towards the camera? Should I be attaching another type of component to instead of a collider? Any advice or suggestions would be appreciated.

EDIT: Just found out what billboard shaders are. Guess I don't need the scripts anymore!

behavior2.png (79.3 kB)
behavior1.png (99.7 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

  • Sort: 

Follow this Question

Answers Answers and Comments

76 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 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 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

Position in relation to another object 1 Answer

Moving a 2D character along the X and Z axis only. 1 Answer

How can i make terrains from 2d map images 0 Answers

How to show a 2D texture through a 3D object like it's a portal? 1 Answer

Camera display specifications,2D visuals in a 3D game with camera issues 0 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