Hi! I want to make a game with some spheres and I have a few questions:
- How do I randomly spawn them on the ground?
- How do I make them interactable (if a character is standing on the sphere, he needs to press F to interact with it for example)
- each sphere does something different according to their color. How do I do that? (let’s say a character picks a sphere. green sphere gives him 20$, the red sphere gives him 50$…)
The overwatch workshop is a really cool place, but I can barely understand how to do stuff (and I’m a programmer, I know how to code)
Thanks!
There are many ways, depend on what you want, do you want them in a square, a circle, a disk, a sphere, a ball a cylinder? It really depends on what you want.
The best bet is to use the “random real” so that you get a random nubmer that can be used to help get a random anything
If you have all of them inside an array (I recommend doing that, it really helps), you can use the following to check if they are near any ball
conditions
{
Is True For Any(Global Variable(Array), Compare(Distance Between(Event Player, Current Array Element), <=, (Size of one ball))) == True;
}
For that you need to store each of the different ball inside different array, and check in different rules each array.
I have a code that could help you see how that works, here it is: T8QDN
It creates random rings in a cylender above the workshop island, they are multiple of them and depending on their color it changes the number of point scored
2 Likes
Thanks! you helped me a lot! Do I have the ability to spawn spheres at random places without colliding with the ground? let’s say I want to make random spheres hovering 1 meter above ground. Not all of the maps are flat. How do I random his place without worrying about the ground?
You can use ray cast position, it creates an invisible beam from the start point to the end point, unless something stops the beam such has a wall or player, in that case it will return where it hit the position.
Let’s say you want to spawn an orb on global variable A
First you create a ray cast that goes down, it will stop at the ground, then you make the global variable A go 1 meter up
Here is an example:
actions
{
Set Global Variable(A, Ray Cast Hit Position(Global Variable(A), Add(Global Variable(A), Vector(0, -10000, 0)), Empty Array,
Empty Array, False));
Set Global Variable(A, Ray Cast Hit Position(Global Variable(A), Add(Global Variable(A), Vector(0,1, 0)), Empty Array,
Empty Array, False));
}
You just need to generate a point where you want the orb to spawn on A, and that depends how you want the randomness to create an orb, you just need to make sure that global A is somewhere above ground and below the ceiling
Here’s a part of a code that does someting similar to what you asked: 07WXG
You can check my game mod with such interaction.
More info about me and my game mods you can find here.
That is because of a condition in the “create effect condition”:reevaluation, you need to set the last option to “none”/“visible to” instead of “Visible To Position and Radius”, the game relocates every orb to extra_heal_loc[i], so it only shows the last position
1 Like
Thank you! you’ve helped me a lot!!
Mareaucanard, do you know anything about “Nearest walkable position” action? it is much better and easier than “ray cast hit position”.
More info about me and my game mods you can find here.
The problem with NWP is that it returns very weird location sometimes, such as inside walls, ceiling and just a lot of OOB places, it can be very helpfull, I just don’t believe it’s the best thing for that specific thing.
Anyway using “Ray cast…” actions are not recommended because of their high cost. By the way, I saw no an issue with “NWP”, never and trust me I made enough scripts to say it for sure. Possible you are just more lucky than me
More info about me and my game mods you can find here.