Im trying to make this type of thing in my game where when NPCs spawn, they are spawned with different clothing styles like a Green Shirt or a Red Shirt and its not a set style its the same NPC Model but with different sprites everytime it is generated
You add a new object, say for Shirt, with different animations or different frames, whichever way you want to go about it, then you make the different shirts inside that object.
Then if you would like to make it randomized you would pick from a number like 1 to 3 for example. 1 is green, 2 is red, and 3 is yellow. You can make a variable and just use the RandomInRange(1,3) to determine which one it is, then do this process for the pants, shoes, hair, or whatever you want!
And to attach the object to the player you could just put an event with no condition and have it go to a point on the player.
Actually you don’t need a separate variable, you can directly set the animation by number:
change the number of the animation of Shirt = RandomInRange(1,3)
You can access the animation number that is currently displayed with Shirt.Animation::Index
Also, instead of using events, I would give the Sticker behavior to the clothing items and then Stick them to the player when created. This will move the item around with the player, and you can also use “is stuck to an object” conditions to pick the clothing objects later.
I see, you only need to stick it once. If you want to use collision to put on the clothing, you will need another condition to prevent this from triggering constantly. You’ll also need to position the clothing as I mentioned… when you Stick an object, the object follows from wherever you Stuck it, which in this case is whatever position you collided with the object.
CAT is in collision with Clothing | Stick Clothing to CAT
Clothing is not stuck to CAT | Position of Clothing = Cat.X(), Cat.Y()
If the clothing sprite is not the same size as the cat sprite, you might need offsets to get it to line up right (i.e. Cat.X() + 1, Cat.Y() - 6)
By the way, to have a “not stuck” condition, look for the “Is stuck to an object” condition and then invert it
so turns out when I had done the shirt randomizations it didn’t quite work right
Because when the player has interacted with the Sprite then it will scroll through different styles instead of staying at the randomly chosen style
An advanced way to do this is with the new custom objects you can create two objects short and body. Use the pre-scene events to set positions (might lag if there are many ais). You can further use on creation to change the clothing animation and make a more editable system.
I don’t see any benefit to this and it doesn’t answer the specific questions being asked.
That’s because you did not add the condition to stop the event from triggering again.
Each event is processed once every game tic. If your game is running at 60fps, that means your events happen 60 times per second. So you have this event where the only condition is “player is in collision with clothing”. So if the player is in collision with the clothing for 1 second, then this event will happen 60 times.
There needs to be another condition that will prevent this from firing off constantly. “Trigger once” is one possible way, but I try to avoid using that since I feel it is better to have direct control over the event. That’s why I suggested adding this condition:
(inverted) Clothing is stuck to Player
With that condition, when you collide with the object it will only go on to do the actions if the clothing is not already stuck to the player. (sticking the object does not prevent collisions)
Can I see how you did it? For “not stuck” you need to invert the condition, either by clicking on the invert condition toggle in the large condition editor dialogue, or by selecting in in the events sheet and pressing J
Ok, the condition is fine, problem is that those are separate events. Drag the “clothing is stuck” condition up to the above event, below the collision part. And drag the “change number of animation” up as well (order doesn’t really matter for that one)
I figured out a way to fix it but I also realized that I can turn it into like a mystery box mechanic as seen in the Mario Kart Games except with clothing!!!