W
W
WasTabon2022-04-17 17:29:59
Unity
WasTabon, 2022-04-17 17:29:59

Changing the size and sprite of an object during the game?

So that from, for example, such a rectangle

625c2429a1c49809330108.png
, it turns into this

625c244861b73092845116.png
If you just throw a sprite, then the dimensions do not change and this is what happens

625c24632badd821595909.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
WasTabon, 2022-04-18
@WasTabon

float spritePos = _collider2D.bounds.max.y + _groundCollider.bounds.max.y;
spritePos = spritePos * 1.5f;
_transform.position = new Vector2(_transform.position.x, spritePos);

Fix for changing the position by colliders (of the object and the ground on which it should stand)

D
Deezalir, 2022-04-17
@Deezalir

Just pull the top blue circle up and make it the size you need.

N
Nekit Medvedev, 2022-04-18
@NIKROTOS

The scale property of the transform component is responsible for the size of the object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question