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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > 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.

    You're Welcome

    I'm just sussing out why it all works together with the events

    If you mean how the UID gets created and saved and then Picked when need it.

    I gave you two different examples;

    1-One for when you create the all the objects on the RunTime is the "On Creation:" Example

    Here as the two Objects (Enemy and Health) are created Together you can save directly the "Health.UID" to the Enemy Instance Variable = "Health_UID"

    Then whenever you need to Pick the Health Linked to the Enemy you use the "Enemy.Health.UID" where is the UID of the Health that we saved on the Start Of layout

    2-The second example is when you have all the objects already created before the Run Time which is the "By Comparing Instance Variables" Example, so you need to link somehow the Two Objects Enemy & Health so we can Pick them and save the UID to the "Enemy.Health.UID" On the start of Layout like we did on Option 1

    But the difference here is that we have to Loop throughout all the Health Instances to see who is Linked to Who.

    This Option requires more To Do as you have to link them by instance Variable and has to be done on the Editor before Run Time.

    If you look at the Enemy Instance Variables you will see "Health_N" and if you look at Health objects Instances Variables you will see "Enemy_N" so these two variables are the one we use to Link them together at the start of the layout so we can save the UID.

    If you look at the editor and check all the Objects Variables you will see this:

    Health_N = 0 ---- Vs -----Enemy_N = 0

    Health_N = 1 ---- Vs -----Enemy_N = 1

    Health_N = 2 ---- Vs -----Enemy_N = 2

    Health_N = 3 ---- Vs -----Enemy_N = 3

    Etc......

    Although you could do this with containers to avoid all extra work is good to know because sometimes depends on the situation you cannot use containers but don't worry you will learn as you go

    Image Points:

    Here is very simple once you do it once.

    Do you know how to Add Image Points right?

    Just in case: Open enemy Object on the Animation Editor Like on Picture

    -Press on number One 1

    -On number 2 I added an Imagen Point with the + Sign and this image point is the second one so it becomes as Index = 1 as you can see on the Picture

    -Now while you are still on that image point Move the Position to where you like it to be, see Number 3

    And that's all, then when you need to reference any image Point you just enter the Number of the Index of the Image Point.

    You can also reference Imagen Points by Name

    Example:

    Instead of set position to image Point =1

    You could do

    set position to image Point = "Health"

    Where "Health" is the name That I give to that Image Point

  • Thank you for explaining this again and taking your time.

    I understand, its quite a clever way of linking the UID, through the variables. That is defiantly an eye opener and can see why and how it is better doing it that way. You could save all this and create a tutorial, I am sure you would help many people.

    Its new to me so it took a while before it really made sense. And it does make sense. However would this still work if one of the enemy's required more damage to get destroyed? Would you just add another instance variable?

    I have tried loads with image points, but no joy. I think its because a ball perhaps? I tried replacing the ball with a stick man and it worked perfect.

    Thanks buddy

  • However would this still work if one of the enemy's required more damage to get destroyed? Would you just add another instance variable?

    If you talking about just General "Health" without displaying the Health Animation Percentage then you could do it in many ways, the simplest one will be to create an Instance Variable "Health" then you can do.

    On collision With Object

    ====>>>>Susstract 1 from "Health"

    =========>>>>>>>Health <= 0: Destroy

    And if you need to display the Health bar Progress then I leave you for you to figure it out as they are many ways to do it, you will have to find the one that suits your needs, they are many Tutorials that you could use.

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

    I have tried loads with image points, but no joy. I think its because a ball perhaps? I tried replacing the ball with a stick man and it worked perfect.

    Set Position to Image Points it should work if you set up everything correctly unless is a bug.

    The Shape of the objects doesn't affect in any way, the two important Factors here are:

    When you set Object A Position to Object B ImagenPoint(X)

    Object A:

    Check the Imagen Point = 0

    As this is the Default Coordinates of any Object that Constructs use to Position the objects on the Grid

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

    Object B:

    Check ImagenPoint(X) if the Image Point its placed in the right Location where Object A you need it to be

    And then when you compare Both Image Points you will easily see if they gonna be positioned like you need to be and if not adjust the image Points as you need.

    However, If you think that both have the Image Points in the Right Places, then without seeing a simple capx example will be hard for anyone to help you as it could be many things:

    I would start from checking if Both Objects are in the same Layer or if they are on different Layers make sure that both have the same Parallax as if you place one of them in another Layer that has Example (Parallax = 0 ) you will have to translate the Coordinates from Layer To Layer

  • > However would this still work if one of the enemy's required more damage to get destroyed? Would you just add another instance variable?

    >

    If you talking about just General "Health" without displaying the Health Animation Percentage then you could do it in many ways, the simplest one will be to create an Instance Variable "Health" then you can do.

    On collision With Object

    ====>>>>Susstract 1 from "Health"

    =========>>>>>>>Health <= 0: Destroy

    And if you need to display the Health bar Progress then I leave you for you to figure it out as they are many ways to do it, you will have to find the one that suits your needs, they are many Tutorials that you could use.

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

    > I have tried loads with image points, but no joy. I think its because a ball perhaps? I tried replacing the ball with a stick man and it worked perfect.

    >

    Set Position to Image Points it should work if you set up everything correctly unless is a bug.

    The Shape of the objects doesn't affect in any way, the two important Factors here are:

    When you set Object A Position to Object B ImagenPoint(X)

    Object A:

    Check the Imagen Point = 0

    As this is the Default Coordinates of any Object that Constructs use to Position the objects on the Grid

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

    Object B:

    Check ImagenPoint(X) if the Image Point its placed in the right Location where Object A you need it to be

    And then when you compare Both Image Points you will easily see if they gonna be positioned like you need to be and if not adjust the image Points as you need.

    However, If you think that both have the Image Points in the Right Places, then without seeing a simple capx example will be hard for anyone to help you as it could be many things:

    I would start from checking if Both Objects are in the same Layer or if they are on different Layers make sure that both have the same Parallax as if you place one of them in another Layer that has Example (Parallax = 0 ) you will have to translate the Coordinates from Layer To Layer

    Hi Buddy,

    Adding a health bar is fine. I ment specifically in your example. You have the blocks in black and the green health bar attached. What if one of those black blocks had a higher health limit? Because the uid is linked, is it possible to increase the health of a chosen black block?

    Regarding the pin. I found a solution. If I changed the ball to a circle collision polygone it worked, but because of physics the ball jumped around. I created a new ball and it worked fine :-). I downloaded the sprite and had somthing weird happen in the pass. No sure what causes it but only ever had a few "glitches" with this sprite!

    Again, thanks for all the help. If I don't here from you have a great new year dude.

  • Adding a health bar is fine. I ment specifically in your example. You have the blocks in black and the green health bar attached. What if one of those black blocks had a higher health limit? Because the uid is linked, is it possible to increase the health of a chosen black block?

    Hi Freddy33

    That's the thing I was trying to explain to you in my last post, those Capx examples that I gave you it was meant to be just as for helping to explain the UIDs (Pick & Link) so the Health System it wasn't meant to be used as you can see the Health system is very basic and Limited so I was more looking to simplify the code to make it easier and friendly to understand the UIDs thing.

    The problem here is that I put the (Health Life Count and the Health Percentage Bar Display) all in one using the "Animation Frames" meaning they are Fusion together as a pack instead of creating an Instance Variable "Health" and then subtracting the Health amount each hit then updating the health bar percentage according to how much Health is left.

    So adding a variety of enemies with different Health Values you gonna have to count with the Max Health that an enemy can have to add all the Frames to display the percentage Bar.

    Example:

    Enemy1 = Health 10

    Enemy2 = Health 4

    Enemy3 = Health 7

    On the enemy (Health = 10) it will need at least 10 Frames to display the health bar percentage but the enemy with 4 just needs four frames and so on.

    So no it's not gonna work unfortunately unless you create all the Animation for all the possible starting Health separate which is not practical

    As I explained in my Last post you need to create an Instance Variable "Health" so you can have enemies with different Health values, then when you substract the values from health you need to have a Health Bar Percentage system to display the amount of the health still left for this they are many ways so you will have to find the one that you like or works well with your project.

    Here is one way of doing it:

    https://www.dropbox.com/s/pte9rg0hcewcf50/Health%20Bar.capx?dl=0

    If you like it then you will have the opportunity to practice the UIDs thing while you set up the system for all the Enemies.

    Regarding the pin. I found a solution. If I changed the ball to a circle collision polygone it worked, but because of physics the ball jumped around. I created a new ball and it worked fine :-). I downloaded the sprite and had somthing weird happen in the pass. No sure what causes it but only ever had a few "glitches" with this sprite!

    Cool glad you fixed man

    Thank you, You too have Grate New Year and a happy New fresh start on Game Development mate

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