count no of instance of object
SANDEEP410
Member Posts: 46
How to to get the number of instance of an object
Also in my scene i want my game to progress to next level if all enemys are dead.So where should i put my conditions,in which actor
Also in my scene i want my game to progress to next level if all enemys are dead.So where should i put my conditions,in which actor
Best Answer
-
MotherHoose Posts: 2,456in any scene: the actors you place in the scene and their rules/behaviors only run in that scene
… each time a scene is loaded …it starts exactly as you programmed it
of course: the current state/condition of gameAttributes
… if used in actor's rules to trigger events/behaviors … are in effect
==
in your scenario … create a small controlActor
… drag in to scene
… then drag offScreen out of the camera area (the large white-lines rectangle)
… unlock it
… Create a rule
Rule: when (All)
Attribute: expression-select Current scene Name is (the name of that scene)
Attribute: game.enemyCount ≤ type in a number
--changeScene
MH
Answers
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
what if i wana find out, if instance of a particular enemy currently exist in the screen.
www.apptekgames.com/enemy.zip
1. If you only need to know whether an enemy has "died," give each enemy a unique self.ID (index) and have a rule that says When [enemy dies] Change Attribute game.deadList (text) to game.deadList..self.ID. Then have another actor offscreen that has a rule When attribute game.deadList contains [actor ID you want to check] then [that actor is dead].
2. If you have a small number of enemies, you can give each one a boolean attribute self.dead and then unlock a separate offscreen actor and set up rules for When attribute Current Scene-->layers-->[layer name]-->[instance name] is true then [that actor is dead]. You can even rename your instances so that you can tell which one is which.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@SANDEEP410 … to monitor an actor's condition in the scene …
you need to uniquely name each enemy
… then add gameAttributes … boolean type … for their condition … active/dead
to show the state of those attributes … use controlActors or displayTextBehaviors
==
or just before the enemy is destroyed change its Alpha to 0
and have a controlActors check/react to the Alpha of each enemy
think you are going to have learn/work with GS
… to get an understanding of the many proper ways to do things
use the demo from AppTek … to get started with this
MH
Anyway Lets say i have a turret that automatically shoots if a spider appears in the scene.
Now how can i determine if a instance of spider exists in the scene or not.
Please don't take this tge wrong way but this is a very basic task. If you are having trouble understanding this then you need to take a step back and work on the basics of gamesalad. Watch the cookbook videos and actually create everything the videos create. Your games quality will improve greatly overall if you take the time to Learn the tool really well. Before diving into a project you intend to publish.
Cheers
I have one more question I want my game to move to next lvl if specific type of enemys are dead.
So is there any way such that a rule will only work for a particular scene.Since i have different type of enemys for diff scene.
I have 50 balloons in a scene. I shoot them one at a time but very quickly so all of them are destroyed within 10 seconds. I log into debugger the number of alive instances every time an instance is destroyed. After I shoot all 50 balloons, I check in debugger and see that the counter went 50->49->48->...->16->15.
Is there a way to guarantee that a certain behaviour action will be executed but doesn't need to be executed immediately?