How do I use the same sprite with two sepparated behaviours?

0 favourites
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • Hi everybody, I'm Juan, so the thing is: Imagine a warcraft type game. So there are these minerals you can farm, I currently have 1 sprite called mineral, and it has a global variable (tried using instance variables, didn't work) wich is the mineral's life. Once you send a worker to the mineral, he starts farming it. Now, there has to be several of these minerals across the map, and idk how to make each of them (wich is the same sprite spread out across the map, the same mineral) has its own life.

    I would be incredibly grateful if someone could help me. :D

  • To have separate life it is the instance variables you stopped using hehe. In what way was it not working?

  • I tought the same, using variable instances was the solution but, when I farm 1 of the minerals, it is like farming all of them, instead of only depleting the #1 mineral's life, #2 mineral's life also was depleting at the same time

  • I have a boolean called "working", when the worker touches the colition of the mineral, boolean sets true, then the instance varaible "mineral's life" starts depleting

  • In theory that sounds fine, if one is set to true then it will deplete the life. Construct has a lot to do with picking instances and applying the actions to those instances. You could share screenshot of the events so we can see how you are approaching it. Also in debug view you can select the instances and see if variables are set how you expect.

    Farming all of them means that it's not using a condition properly such as 'sprite boolean = true, subtract from sprite variable' and is instead picking all the sprites. You can narrow it down with conditions, just make sure they are in the correct structure.

  • This is the code, and I've been fixing stuff on the debug, but I genuinely don't understand how to fix the issue.

  • You need to pick the same thing you are applying the action to. In this case you could put the 2 objects in a 'container' so they relate, but in general you need to pick on the left what you apply on the right.

    Because you are not picking a mineral on the left (normally would be the one you overlap if you chose the mineral object) it sets variable for all minerals. You could also move the variables to the mineral collision object if the mineral itself is just for visual. As it stands, when you overlap a mineral collision it won't know which mineral to choose as they are unrelated.

  • when you say left and right, you mean, the properties and the event sheet (in that order)?

  • left and right of the event sheet. left is the conditions where you narrow down which instances that the actions on the right should be applied to. In your event you say on collision with mineral collision, then set a variable on a different object, mineral. But these two are unrelated. Normally it would be the same object. There is an exception though called a 'container' where you can put the mineral collision and mineral in a container together and they kind of relate to each other. But at the moment I would stick to using one object here, for collision and variables.

  • Ahhhh, well lmao that was quite easy to fix. But I have one little thing, There is a text above both minerals that shows the mineral's life number. But when both minerals are being farmed, the text starts to spawn infinite times D:

  • I know why they spawn infinite times, but don't know how can I make the text work as I would like to.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You don't need to keep spawning them but place one next to the mineral. Then you need to relate them, you could use text is overlapping mineral, set text to mineral.var, if they're touching. Or you could use pick nearest mineral nearest to text. Bit confused about what you were trying to achieve with the spawning and 1 second wait.

  • Sorry but I didn't understand :/

  • I tried it and it didn't work

  • I assume you're trying to display the value for each mineral. Each mineral instance needs a text object next to it. If you have it overlapping the mineral object you can say mineral overlapping text - set text to mineral.var

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)