#I'm a begginer.

1 messages · Page 1 of 1 (latest)

nocturne egret
#

@modest yacht
We're starting this conversation over in a thread. You should disregard Gonz, they're just confusing things.

#

The Sprite Renderer is the thing that determines what sprite an object displays

#

You can change that component's .sprite to change which image is displayed

#

So, the first step, make a public SpriteRenderer spriteToChange and drag in the object with the SpriteRenderer

#

This sets the object you want to change the display of. Whenever you want that to change you'd do spriteToChange.sprite = someOtherSprite

modest yacht
#

ok, so I'll explain more:
https://youtu.be/0RS0aOx4fGc at time 3:14

I'l trying to recreate a OMORI styled fight scene, more particulary the frame around the characters witch says the "Emotion" like Happy --> Angry

Here is the fight with Perfectheart from OMORI. This is to show the initial meeting with her and that it is possible to beat her without anyone falling... (with item spam of course!) All items used are buyable from the boss rush item shop
Please support the Omocat team by playing this masterpiece

Steam: https://store.steampowered.com/app/115069...

â–¶ Play video
nocturne egret
#

The next question being "how to get someOtherSprite, which there are a few ways. If you know which one you want, you could make a public Sprite ____ variable, and use that name.

nocturne egret
nocturne egret
#

Then, whenever you want to change it, like, let's say if your health is above 50, show happy, if it's below 50, show angry, you'd do something like this in Update:

if (myHealth > 50) {
  faceBox.sprite = happyFaceSprite;
} else if (myHealth <= 50) {
  faceBox.sprite = angryFaceSprite;
}
#

That changes the renderer's sprite to be the one you define

#

Now, you can put this script on multiple objects in the scene, and for example on Omori drag in those specific images, and on Aubrey drag in different images

#

the logic is the same on all of em, but since you've set them in the inspector, they can all have different values

#

You can make things a bit more advanced using a Dictionary, but unless you've got like, more than ten sprites per object I wouldn't worry about it.

modest yacht
#

OK the .pngs are dragged

#

now I need the SpriteRender to drag in and then calling the SpriteRenderer.frame = ThisOne when I need

nocturne egret
modest yacht
#

THX

nocturne egret
#

You can drag in the child object with the renderer on it into the slot, and it'll automatically pick up the Sprite Renderer component on it

#

You don't have to worry about dragging in the component directly, just the whole object from the hierarchy into the slot will work

modest yacht
#

Thank you very much, I learnt a lot with this

nocturne egret
#

and sends someone down the wrong path