please help! View to move after array of actors destroyed.

Game Editor comments and discussion.

please help! View to move after array of actors destroyed.

Postby ckn087 » Sun Oct 30, 2016 2:31 am

I cant seem to get help with this one. I have made level 2 with 2 actors. Enemy 2.0 and enemy 2.1. I clicked the clone option on 2.0 to get 2.1. I'm wanting it to where the view will move over to next level (which I know how to make view move) only after both actors have been destroyed. I have made a variable (enemy_units) this is how I have it: On enemy 2 I have: Create Actor/Script Editor: enemy_units =2; Destroy Actor/Script Editor: enemy_units --; and Draw Actor/Script Editor: if (enemy_units ==0)
{
View.x +320;
}
What am I doing wrong here? Thanks!
ckn087
 
Posts: 30
Joined: Thu Jan 14, 2010 12:29 pm
Location: U.S.A
Score: 1 Give a positive score

Re: please help! View to move after array of actors destroye

Postby lcl » Sun Oct 30, 2016 10:09 am

Your code in Draw Actor will not be executed, because by the time when enemy_units is equal to 0, you have already destroyed both enemy2 actors, so there is no one left to execute the Draw Actor code. Move the code to the Destroy Actor event, after the line where enemy_units gets decreased by 1. Then it will work.

This is a better approach for another reason as well. That is because you shouldn't use Draw Actor unless the code really needs to be executed every frame. Try to always place codes to the correct events. In this case correct event is the Destroy Actor -event, because you want the view to move after an actor has been destroyed, and Destroy Actor -event gets executed exactly by the time the actor os getting destroyed.

Also a couple of things about your code there. It's "view", not "View". Code in GE is case-sensitive. And you probably meant to write:
Code: Select all
view.x += 320;

Without the = this code will not move the view anywhere.

And one last thing. Don't make multiple topics about the same problem. This is your second topic about this issue, and of your previous, very similar issue, you made at least three new topics. I know you do it in hopes of getting help faster, but actually it may make people hesitate to help you, because they can't know which of your topics are already "old", i.e. solved.

So, instead of making new topics, just post a new reply to the one you already have, and update your status regarding the problem. Posting a new reply will bump that topic up to the top of the forum section and label it unread for all logged-in users. This is the correct way to ask for help. Only make a new topic, if you have a new problem unrelated to the original one.

Anyway, I hope this helps! :) If you still can't get it to work, just ask here, and me, or someone else, will help you. Good luck to your game-making! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: please help! View to move after array of actors destroye

Postby ckn087 » Sun Oct 30, 2016 1:00 pm

My bad on topics. I am pretty new to all this so I'm still learning lol. And yes I never put a capital V in view in the actual game. I should've wrote it correctly here and the = I also put into it. But thank you! I'll try the destroy actor instead of draw actor.
ckn087
 
Posts: 30
Joined: Thu Jan 14, 2010 12:29 pm
Location: U.S.A
Score: 1 Give a positive score

Re: please help! View to move after array of actors destroye

Postby ckn087 » Mon Oct 31, 2016 3:42 am

Hey guys I still need a little help. I did like you said and made the
if(enemy_units ==0)
{
view.x =+ 320;
}
on destroy actor event instead of draw actor but now instead of the view moving after both of the actors being destroyed, it moves when 1 is destroyed like the variable is only adding 1 instead of 2. Hope that makes sense. I made the create actor: enemy_units = 2; on enemy 2.1 hoping it would make each actor have that 1 variable so that when one was destroyed it would - 1 of enemy_units. Let me explain here what I am doing as far as making my first enemy actor. On level 1 I made an enemy actor (enemy 1.0) level 2 I made 2 enemy actors (enemy 2.0 and 2.1) On level 3 I was gonna make 3 enemy actors (enemy 3.0, 3.1, and 3.2) maybe I'm doing this wrong. should I clone the very first one on level 1 (enemy actor 1.0) and clone enough to cover all the levels I want that actor in? Is there a way to reset or change a variable as the levels progress? I'm sorry if this is confusing as I am very new to game editor. I just want it to where view moves right after level 1 enemy is destroyed which I have that much going for me and the view to move right to level 3 after the 2 enemy actors are destroyed on level 2 and so forth. I appreciate everyone's help very much!
ckn087
 
Posts: 30
Joined: Thu Jan 14, 2010 12:29 pm
Location: U.S.A
Score: 1 Give a positive score

Re: please help! View to move after array of actors destroye

Postby ckn087 » Tue Nov 01, 2016 11:37 pm

I may have got the order of view.x =+ backwards on that last post. Meant to put view.x += :D
ckn087
 
Posts: 30
Joined: Thu Jan 14, 2010 12:29 pm
Location: U.S.A
Score: 1 Give a positive score

Re: please help! View to move after array of actors destroye

Postby lcl » Wed Nov 23, 2016 10:43 am

Hi! Sorry I took so long to get back to this.

Your setup sounds like something that could work, even though it may not be the easiest way to achieve what you want. I myself would only create one enemy actor, and clone that one actor across all levels. At the beginning of each level I'd set the enemy_units variable equal to the amount of enemies in that level, so that when that amount of enemies is destroyed, the game knows that it's time to move on to the next level.

But let's try to work on what you have now. First, one question. How have you defined your enemy_units variable? Is it a Global Integer variable? That's what I'd assume.
Also, notice that you can't add events clone specifically. What that means is that when you say:
ckn087 wrote:"I made the create actor: enemy_units = 2; on enemy 2.1"

You are misleading yourself. That code is not added only for enemy2.1, but also for enemy2.0 - all clones of the enemy2 actor. Clones always share the same events. Within those events it is possible to do some clone-specific coding by using cloneindex or clonename to distinguish between different clones.

Now, seeing your .ged project would really help me to help you, because that way I could see the whole picture of what you have done, and find what is causing the trouble. But because at this moment I don't have that, I'll try to work based on what you've said.

Are you using the same enemy_units variable for the first level? If you are, are you also setting the variable to some value at the create actor event of the enemy1 actor? If you are, then there's your problem. Let's analyze what happens when your game is run.

I'm assuming all your enemy1 and enemy2 actors get created at the moment when the game starts. So, when game starts all enemy1 and enemy2 actors execute their Create Actor event. All clones of enemy1 set the enemy_units variable to the amount of enemies on the first level, and all enemy2 clones set the variable to the amount of enemies on the second level. Now, the actual value of the variable depends on what code gets executed last. And most likely that is the last enemy2 clone. So now, the variable would be holding the value 2. Now, I assume that your first level has 2 enemies, right? Because if it had less, your game would have never moved to the second level with this setup, and instead of asking your current question, you'd be asking why your game does not continue to the second level. And if it had more, you'd be asking why your game goes to the second level too early.

If my guess on how you've built your system is correct, then it will be an easy one to fix. However, I won't now go into details about if before being sure, that I'm on the right track. Because if your setup is different to what I think it is, the solution could just make everything more broken. So, can you please tell me if my assumptions are correct or not, so I can continue helping you? Alternatively, you can also zip your .ged file with the data folder and send it to me, so I can have a look at it and then help you find the solution to your problem. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: please help! View to move after array of actors destroye

Postby ckn087 » Fri Nov 25, 2016 4:08 pm

Hey lcl! Thanks for the reply. Yes I got a bit anxious waiting but that's perfectly ok lol. I will have to check when I get home but I'm almost 100% sure it's set to global integer. I will definitely send you a ged file. As I said, I'm pretty new to this so I know my setup is gonna be confusing and possibly crazy compared to most. I do what works for me! I don't have a enemy_units variable on level 1. All I have is a variable to make the only enemy actor in level 1 die after 2 hits. Then I have a small timer set so the view doesn't move immediately. I think I used a destroy actor create timer view move setup on level 1. Level 2 there are 2 enemys which I have the enemy_units variable set to 2. It works on level 2. Once I hit level 3 with my 3 enemy actors is where I'm having problems. If I hit any one of the 3 it moves the view early instead of waiting til all 3 are destroyed. Hope that makes sense! I'll definitely have more questions for you since you seem very experienced at this. Thanks!
ckn087
 
Posts: 30
Joined: Thu Jan 14, 2010 12:29 pm
Location: U.S.A
Score: 1 Give a positive score

Re: please help! View to move after array of actors destroye

Postby Zivouhr » Fri Nov 25, 2016 7:20 pm

Good tips Lcl. 8)
------
Clones can get more complex when trying to give certain commands as I found out.
Game Editor would be easier to work with if we had the option to duplicate a template actor (that we created) instantly, and then make significant changes to the new actor rather than coding the variables and keeping it all connected for the varied clones of the single actor. At the same time, it is nice to have everything compact within that one actor for all of the varied clones, movements, directions, patterns, animations and sprites connected to it. :idea:
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron