Search Unity

Creating platforms based on mouse position

Discussion in 'Getting Started' started by patrick750, Nov 29, 2019.

  1. patrick750

    patrick750

    Joined:
    Nov 29, 2019
    Posts:
    14
    Hiya,

    I'm very new to Unity. I've been trying to write code that will take the user's mouse position on mouse down, then on mouse up and place a prefab. The prefab would then be stretched to fit the dimensions of the rectangle the player 'drew' with their mouse.

    So far I have tried doing this via placing it and updating the SpriteRenderer component. This would place the prefab of varying sizes, but couldn't figure out how to align it, scale it the way I wanted.

    Also tried using Rect to build a rectangle and trying similar things.

    Could someone point me in the right direction?