0 Favourites

[SOLVED] Create New intance of same object (which is picked)

  • Solution: You use functions ...pass along the variables you want via paramaters to a function that generates the enemy and use the paramaters to set it's instant variables

    G'day again guys.

    Unsure if this is a "How do i" or a 'beginners question' so i chose the later because I believe if I had more experience I'd already know the answer:

    I've tried a few things but it's not working right I believe it has to do with identifying the instances.

    Essentially I need to completely clone the Enemy as another instance and then change at least one instance variable of the new clone. (instance variable isn't shown in the below list as I don't see it being an issue.)

    Information:

    Enemies are basically bouncing balls.

    If they hit the ground

    Triger Simulate Jump

    Triger Gravity +10

    Triger JumpStrength -10

    I am attempting to:

    When the bullet hits the (original)Enemy:

    Create Explosion (no problems here)

    Create Enemy(instance#2)

    Set Enemy(instance#2) gravity and jumpstrength to that of (original)Enemy

    Set Enemy(instance#2)scale 0.75 (no problems here)

    Create Enemy(instance#3)

    Set Enemy(instance#3) gravity and jumpstrength to that of (original)Enemy

    Set Enemy(instance#2)scale 0.75 (no problems here)

    Destroy (original)Enemy ..... (I have to do it here because I need to refernece it for the properties

    Destroy Bullet

    I'm ok with not destroying the original Enemy (but changing it's scale) but still having issues with the assigning of the properties.

    Any ideas / tips / direction?

    Thanks in advance :*

  • humpty If you would like to post your capx you can!

  • Sorry Apox Inc :/

    I try to write the question in a way that doesn't require someone to DL something, load it, look through etc.

    I think I will start just uploading capx's though as well.

    For now though I will check out functions. I believe they will be my saving grace as i can pass variables through to them it seems

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • humpty No problem! It's just easier to see what you're working with when provided a capx. You can most likely work something out messing around with the variables and events a bit. Do you know anything about the global values and instance variables?

  • 'global values' no instance variables yes.

    I understand from other programming what global variables are though.

    It will be nearly 1/2 the day before I get to look into the functions first. I'll start there then do a search on global values.

  • Yup!

    Functions were the answer. Thanks Apox Inc

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
New Android Export Experiences
494 67,283
jabk's avatar
jabk
Unread hot topic
410 84,626
MrMegawatts's avatar
MrMegawatts
Unread hot topic
392 34,836
Joannesalfa's avatar
Joannesalfa