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 youngapprentice · Jan 26, 2013 at 06:33 PM · javascriptindicatoroffscreen

OffScreen Effect

Hi, all! I am trying to achieve the offscreen indicator similar to that in Super Smash Bros (something we can all relate to, hopefully).

alt text

Check the upper left hand corner to see what I mean.

Luckily, I am not trying to get something that complicated. I have my sprites renderered, and I have the code to check if it is offscreen.

EDIT: I am trying to get the 'position copying' action, NOT the 'player in the circle' effect. I have simple symbols that I am using. I just want the circle to copy the player's position but be clipped to the screen like the blue circles are.

I would just like to know how I might have the offScreen sprite copy the position of the offScreen player. (If Peach in the image were lower, the indicator would be as well).

Hopefully I have relayed my message well enough. I hope I can get this to work!

Thanks! - YA

Comment
Add comment · Show 3
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 Setzer22 · Jan 26, 2013 at 07:37 PM 0
Share

The only way I see to do this is to render a camera view in a screen texture. Unfortunately, this is a Unity pro only feature so if you don't have Unity pro you won't be able to do it like this.

Another way would be to just display that circle-like texture on the screen and then placing an actual 3d model on it, which shares the same model and animations as the offscreen model.

avatar image youngapprentice · Jan 26, 2013 at 07:50 PM 0
Share

Thanks for the advice, but I think you missed the point. This is not what I am after. I have simple sprites rendered already (simple red triangles). I'm not trying to get the camera-circle effect. I am just trying to copy the position.

avatar image Setzer22 · Jan 26, 2013 at 09:05 PM 0
Share

Oh okey, I thought you ment making your character appear as a picture on the screen when he's offscreen like it's done on ssbm

1 Reply

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

Answer by robertbu · Jan 26, 2013 at 08:34 PM

For a 2D game, the indicator is fairly easy. Here is a starter script:

 public class Tracker : MonoBehaviour {
     
     public GameObject goToTrack;
 
     void Update () {
         Vector3 v3Screen = Camera.main.WorldToViewportPoint(goToTrack.transform.position);
         if (v3Screen.x > -0.01f && v3Screen.x < 1.01f && v3Screen.y > -0.01f && v3Screen.y < 1.01f)
             renderer.enabled = false;
         else
         {
             renderer.enabled = true;
             v3Screen.x = Mathf.Clamp (v3Screen.x, 0.01f, 0.99f);
             v3Screen.y = Mathf.Clamp (v3Screen.y, 0.01f, 0.99f);
             transform.position = Camera.main.ViewportToWorldPoint (v3Screen);
         }
         
     }
 }

It used the fact that when you convert a world point to a viewport point, the values for x and y will be between 0 and 1 if the point is visible. You have to fudge the number a little, since this check will be for the position of the object and does not take into account the object's size.

For 3D, things are more complicated. See this post for a starting point:

How To Make A 2D GUI Arrow Point At A 3D Object

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 youngapprentice · Jan 27, 2013 at 08:49 PM 0
Share

Thank you very much!

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

Offscreen target indicator- how to do it??? 1 Answer

How to animate an object outside of camera field of view? 1 Answer

Learning Scripting (Next Step) 2 Answers

UnityScript equivalent of JavaScript objects 2 Answers

Using Yield waitforseconds with boo 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