Here's the situation: I have three spawn points, each with a boolean variable 'Selected' that is by default set to FALSE. I have events that allow the player to spawn an object at these spawn points when they are selected.
The problem is, a player may select multiple spawn points and spawn a single object that gets placed in all of the selected spawn points. I want to restrict the player to only being able to spawn one object at a single spawn point. In addition, I want the user to be able to switch the selected spawn point at any time before spawning an object. For example, if the player selects spawn point A, but then selects spawn point B, I want spawn point A to no longer be selected and any object spawned will be created at the currently selected spawn point (point B).
This is more or less an abstract question of how one might implement this, but if you want to see a .capx you can use the link below:
Something like this?
cvp Yes, that's perfect!
I'm a little confused though. SpawnPoint.SpawnPointNumb has no entry, so how does this work?
Sry what to you mean by no entry?
Do you mean initial value? i hardcoded that. If you click the different spawnpoints in the layout you can see the variable is set.
cvp Oh :(
I guess I will have to dynamically set the spawnpoint values then.
That should be no problem. if you add spawnpoints on the fly just have a global variable named spawnpointCount. Then each time you add a spawnpoint set its spawnPointNumb to spawnpointCount+1 and also count up spawnpointCount --> spawnpointCount = spawnpointCount + 1
There should be a built-in variable SpawnPoint.Count that you can use, so no need to create the global variable ;)
Maybe you can use one global variable "spawnPointSelected" (for example), instead of boolean for each spawn point.
So when the player selects a spawn point, set spawnPointSelected with its name (or id, or number). And to spawn an object, use this variable to choose the good spawn point.
if spawnPointSelected = A, spawn object to point A
if spawnPointSelected = B, spawn object to point B
So you have only one active spawn point.
I hope it's helpful.
Oops too late !
Excal .... ahh true <img src="smileys/smiley1.gif" border="0" align="middle" />
But... then again.. that only works if you do not destroy spawnpoints. otherwise you can get 2 spawnpoints with the same number.
spawnpointCount = 0
gets number 1
spawnpointCount = 1
gets number 2
spawnpointCount = 2
gets number 3
spawnpointCount = 3
destroy spawnpoint 1
You see what i mean... So if you destroy spawnpoints you have to keep track of the numbering yourself.
Develop games in your browser. Powerful, performant & highly capable.
For dynamic number of spawn points, I think you can use Pick by unique ID.
So no need to use a spanwpointcount variable. When the player selects spawn point, set global variable spawnpointselected to the spawn point uid.
cvp this is true. I guess I have to make the global variable after all :(