How do I get each bullet to change an animation? capx attached

0 favourites
From the Asset Store
3 pixel charaters with over 8 animations each + animations with a gun
  • Hi, thanks for any help. I have been asking alot of questions recently but I am constantly getting stuck. I think its understanding of events and inexperience. I have searched the forum but cant find anything relating.

    I am basically trying to get the snowball to change animation when each bullet hits, so the first bullet sets the snowball animation to the first frame, the second bullet sets the snowball animation to the 2nd frame and so on.

    Its proving quite tricky and I know im not doing something right, any suggestions please?

  • Take out the for each and pick by UID.

    What is the animation0 variable doing?

    I would do

    bullet on collision with snowball,

    if animation frame = 0 - set animation frame to 1

    if animation frame = 1 - set animation frame to 2 etc as sub events

    There are ways to make it more efficient but try this for now.

  • Hey Plinkie, thanks for all the help you offer me.

    Its not working, but i know this is because I am not seeing the logic properly.

  • does this solves your issue? change frame on hit

  • Freddy33

    I see two problems here:

    1-How could you possibly know it will exist a (Snowball with UID = 150) Before the Game starts? I see it could be done by Picking by IID if they were 151 snowballs but I cannot see this working by UID if you wanna target a Fix "Instance Number"

    2-On the collision Event construct (Picks or adds) the snowballs that are involved in the collision so you don't need the extra Pick by UID unless you wanna apply all the Actions to a different snowball that it wasn't involved on the Collision which in this case to use the Pick by UID you will need to reset the Picking.

    You can Reset the Picking by example most common three ways:

    -System >>> Pick All>>Chose "Snowball">>>Then you can use Pick by UID from any snowball

    -You can Add the snowball to a "Family" and then use the Pick by UID but choosing via the Family

    -You can Call a Function and o the Function Pick by UID

  • does this solves your issue? change frame on hit

    Hi Buddy, thank you very much for finding that, where did you get that from?

    that done the trick

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Freddy33

    I see two problems here:

    1-How could you possibly know it will exist a (Snowball with UID = 150) Before the Game starts? I see it could be done by Picking by IID if they were 151 snowballs but I cannot see this working by UID if you wanna target a Fix "Instance Number"

    2-On the collision Event construct (Picks or adds) the snowballs that are involved in the collision so you don't need the extra Pick by UID unless you wanna apply all the Actions to a different snowball that it wasn't involved on the Collision which in this case to use the Pick by UID you will need to reset the Picking.

    You can Reset the Picking by example most common three ways:

    -System >>> Pick All>>Chose "Snowball">>>Then you can use Pick by UID from any snowball

    -You can Add the snowball to a "Family" and then use the Pick by UID but choosing via the Family

    -You can Call a Function and o the Function Pick by UID

    Thanks for that infor. But the uid is here?

  • > does this solves your issue? change frame on hit

    Hi Buddy, thank you very much for finding that, where did you get that from?

    i made it for you, simple basic use of Construct :) there are a lot of things in my google drive folder need to arrange some stuff to share it online though. im glad it helped u

  • Aww thanks man, I appreciate you taking your time to do that.

    I have saved it to my learning folder.

    Thanks again for that, I literately was pulling my hair out.

  • Freddy33

    Right, you using the Editor I see now, I wouldn't recommend you to rely on the Editor though, the best thing is to get used to saving the UIDs that you need on a Variable at the start of the Layout. To have more control and freedom.

    Example when you work on the Games you are constantly changing things Testing, updating and deleting sprites events etc... so what I'm trying to say you don't wanna get your Events to lock to one concrete UID from the Editor, instead what you could do is to Lock them to one "Variable" so at the start of the Game you set that variable to the UID you need. This way you don't have to be worry if you delete the specific UID that your Events where targetting because they could change if you are not careful by deleting them by accident and creating new sprites on the editor making you hunt and change all the events that where Referencing the UID, and this only if you are lucky to be aware that you deleted the UID that you were targeting as it could happen that you delete it and you not aware that it was the one with that specific UID that you were referencing on your Events.

    I think it would be easier if I give you a simple example because I don't want to bore you with a long post jeje

    So here is my capx: https://www.dropbox.com/s/jgnyzrkenrc0y1x/Pick%20by%20UID%20From%20Editor.capx?dl=0

    -As you can see I'm targeting (UID =8) before the Games starts so far good

    -Now on the editor delete the green sprite with UID = 8

    -And now create another instance of the blue sprite3

    -Now let's bring back the instance that I delete from the Green sprite so make another instance of the Green sprite

    -As you can see there is no more Green Sprite with UID =8, in fact, you can create as much as you like of the green sprites and you would not get any with (UID =8) that's why I say be careful with doing these types of events referencing UID from the editor as it wouldn't be practical in the long-term as you can easily forget deleting and creating while testing etc... but obviously it's your Game you decide, I hope I didn't bore you with the long post.

    Anyway I'm glad that you fixed your problem

  • Freddy33

    Right, you using the Editor I see now, I wouldn't recommend you to rely on the Editor though, the best thing is to get used to saving the UIDs that you need on a Variable at the start of the Layout. To have more control and freedom.

    Example when you work on the Games you are constantly changing things Testing, updating and deleting sprites events etc... so what I'm trying to say you don't wanna get your Events to lock to one concrete UID from the Editor, instead what you could do is to Lock them to one "Variable" so at the start of the Game you set that variable to the UID you need. This way you don't have to be worry if you delete the specific UID that your Events where targetting because they could change if you are not careful by deleting them by accident and creating new sprites on the editor making you hunt and change all the events that where Referencing the UID, and this only if you are lucky to be aware that you deleted the UID that you were targeting as it could happen that you delete it and you not aware that it was the one with that specific UID that you were referencing on your Events.

    I think it would be easier if I give you a simple example because I don't want to bore you with a long post jeje

    So here is my capx: https://www.dropbox.com/s/jgnyzrkenrc0y1x/Pick%20by%20UID%20From%20Editor.capx?dl=0

    -As you can see I'm targeting (UID =8) before the Games starts so far good

    -Now on the editor delete the green sprite with UID = 8

    -And now create another instance of the blue sprite3

    -Now let's bring back the instance that I delete from the Green sprite so make another instance of the Green sprite

    -As you can see there is no more Green Sprite with UID =8, in fact, you can create as much as you like of the green sprites and you would not get any with (UID =8) that's why I say be careful with doing these types of events referencing UID from the editor as it wouldn't be practical in the long-term as you can easily forget deleting and creating while testing etc... but obviously it's your Game you decide, I hope I didn't bore you with the long post.

    Anyway I'm glad that you fixed your problem

    Hi Tarek

    Firstly thank you for taking your time to do that for me.

    I have carefully read over the post and liked into your example and I know exactly what you mean. Using the uid from the editor then deleting that sprite will delete all the events associated with it. I can see how this would be a problem.

    Although I am unsure on how to go about creating an instance variable with a uid so this dosent happen?

    This was really interesting and possibly saved a lot of time. You should submit it as a tutorial because this must affect people.

    I appreciate the time.

  • Hey Freddy33

    No Problem mate I'm Glad that helped you

    Before anything, I would like to point out that the Post got deviated and that we are talking about how to store UID and Pick them in general so what I'm about to write it has nothing to do with your original problem which it got fixed already as you didn't need to Pick by UID, I say this just in case because I don't wanna confuse you, so now we are strictly talking about how to Store UIDs & Pick them in General.

    Although I am unsure on how to go about creating an instance variable with a uid so this dosent happen?

    Would be easier if you give any Example of any situation that you need to store UIDs so you can easily relate to it other ways its impossible to give an example as the range for Picking are endless and it varies depends on the situation or Mechanics that you are doing.

    There are many Types of Picking as an example you got

    -Pick By (IID or UID)

    -Pick By "Comparison"

    De difference between (IID or UID) Vs "Comparison" is that Picking by (IID or UID) Picks directly the object or Instance without looping through all the Objects or Instances as Opposite of Picking by "Comparison" which has to loop through all the Instances of the Object to filter who match the "Condition" therefor adding them to the "Picking List" which means they are automatically Picked so any Actions that you have on that Event they will Apply to all the Instances Picked on the Picked List

    So if you have a lot of Instances of an object the best results you can get its to pick by "UID" whenever is Posible to avoid unnecessaries Loops. But if you don't have many Instances Picking by "Comparison" its fine

    As you can see Picking By (IID or UID) have only Two Possibilities but Picking By "Comparison" has a huge range of possibilities that you can use to give some examples:

    You can use them To Pick or you can use them to filter the already Picked List

    Example:

    -Is "Attack" Animation Playing?

    Any Instances that matches the Condition is Picked so any Actions from this event will apply to all the Picked instances that are Playing "Attack" Animation

    -Is Frame = "5"

    The same as above any Instances that have (Frame =5) are Picked

    Some Times it's not enough with one condition to filter the ones you need to Pick so you can add as much as conditions as you need

    Example Two Conditions:

    -Is "Attack" Animation Playing?

    Is Frame = "5"

    So here unless the Instances are Playing Animation "Attack" & the Frame =5 they will be not be Picked but any instances that match both conditions it will be Picked

    ====================================

    So basically Anything that you can use as a reference to Pick the ones you need its good, this will vary depends on the many situations you will encounter, there is no specific method to Pick, the method will be based on the circumstances, example someTimes you will Pick by

    -Instance Variables

    or

    -Booleans

    or

    -Positions

    or

    -Behaviours

    Etc.... etc...

    And finally just to give a random example as to how to store and Pick by UID most probably has nothing to do with your Project but it is just to have an overview. Although you could do this with containers without the Need of UIDs it is just for training purposes

    On Creation:

    https://www.dropbox.com/s/bsziylubzheuqxb/1-Pick%20By%20UID.capx?dl=0

    By Comparing Instance Variables

    https://www.dropbox.com/s/llf5bcub30h1pny/2-Pick%20By%20UID.capx?dl=0

    I hope you get an idea and that I didn't confuse you

  • Hi Tarek.

    Thanks very much for such a detailed example. I appreciate it.

    Even though im still very much a beginner, your example made sense straight away. The way its laid out for sure. Its a really good example. Im just sussing out why it all works together with the events. I do understand somewhat though. I think its the expressions within the events that confuse me the most.

    I learnt not only about uids, but pinning as well. I knew how to pin, but never used the position on a pinbox like this.

    Just going to study this so I know the ins and outs.

    Thanks dude.

  • Im actually having a really hard time sticking the shoot box in front of the ball? the position thing is not working?

    Any ideas please?

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