Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Instantiate prefab at grid location

Discussion in '2D' started by JUGoWATER, Jul 16, 2021.

  1. JUGoWATER

    JUGoWATER

    Joined:
    Jul 15, 2021
    Posts:
    2
    Is it possible to instantiate a prefab inside a coordinate of a grid object? I'm trying to instantiate a health bar prefab that generated inside a canvas but it spawns based a location in the canvas (in pixels). How would I go about doing this?
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    How are you instantiating your prefab? You may not want to parent your instantiated prefab as a child of your Canvas object as that would inherit from the positioning of that object.