Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

On Screen Pointer/Indicator for Game Objects

Discussion in 'Assets and Asset Store' started by nustianrwp, Apr 3, 2024.

  1. nustianrwp

    nustianrwp

    Joined:
    Jan 28, 2016
    Posts:
    4
    Asset Store (unity.com)

    This plugin simplifies the on-screen direction indicator which is a common feature in 3D games where an arrowhead points toward a game object, the next waypoint, an enemy or an objective.

    Setting up this system is pretty straightforward.
    • There are a total of two scripts OnScreenPointerController and OnScreenPointerObject.
    • OnScreenPointerController is a singleton. This script mainly contains the environment info needed for this plugin.
    • OnScreenPointerControllerneeds two references. Camera related to player and ui RectTransform .
    • RectTransform will contain all the pointers. The purpose is to have one place for managing all pointers.
    • OnScreenPointerController has a Camera reference. If its null, the plugin will try to find the Main Camera.
    • uiImagePrefab: Prefab configured for inScreenSprite/outScreenSprite. Can be a complex assembly of views chained together. However, the current implementation assumes that parent Prefab will have an Image component.OnScreenPointerObjectis attached is to target a game object whose position we intend to track in real-time during our gameplay session. offset_local is the normalized screen size in x and y-direction. During the final result calculation, offset_local.x is multiplied with screenWidthand result is the padding from screen edges. (the same process repeats for yandscreenHeight). MoveInCicle places pointers at a fixed distance from the screen center. A smaller dimension is chosen from screen size and the pointer is placed along that angle. Distance from the center is controlled by circleSizeNormalized. Example: pointer is placed at a mid-way from screen center to screen edge when circleSizeNormalizedis 0.5 inScreenSprite: Pointer Image when the object is within screen area whether visible or not. outScreenSprite: Pointer Image when the object is not on screen. The object may be in front of the player but not in the periphery of the camera view. The object may be in the back of the player/camera.