Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
OK, I'm not that bright but I don't understand why this works:
Set Position to: choose(spawn1.X,spawn2.X,spawn3.X)
But this doesn't:
Set Position to: spawn(choose(1,2,3)).X
In my mind the output should be the same. Can anyone enlighten me, please?
Noncentz705 Set Position to doesn't accept strings like that either, unfortunately. Believe me, I've tried. :)
Yeah, sorry about that. One solution may be to place the objects inside a family. Then you just pick a random instance in the family and then position your object to the selection.
<img src="http://i.imgur.com/pQ7dQeU.png" border="0" />
Develop games in your browser. Powerful, performant & highly capable.
"Choose" is a value of either text/number format whereas when using the "Create" action expects/let you spawn an instance of an object type.
The second form uses object expressions. See the section on object expressions in the manual.
The expression you gave will pick either 1, 2 or 3, and use that as an index ID (IID) to the 'spawn' object, and return that instance's X co-ordinate. If this is not a syntax error then there must be a different kind of object in your project called 'spawn', so you are using the X co-ordinate of an entirely different object. Your first example uses dfferent object types with different names (spawn1, spawn2 and spawn3) but the second expression will never look at those object types.
In short, it's probably working correctly but you have misunderstood what the expression is supposed to do.
Thanks. I probably shouldn't have posted this in the first place since I was able to achieve what I needed to the first way. I was just curious as to the difference. I understand now. Thank you.