Discuss Scratch

Scratch_Master789
Scratcher
7 posts

"Spawning" a sprite in a random place a certain distance from another sprite

I am trying to create a game where you need to prevent objects from hitting a different object that moves around randomly, I have tried many different times with no success, the object still sometimes goes inside the other object which causes the loss of tens of lives (You only get 10 to start with). Trying it so it picks a random number between -1 and 250 that is also has a distance of greater than 100 from the object only result in the sprite going to 0 and moving from there.


Any help would be greatly appreciated.
Thanks,
Scratch_Master789

Last edited by Scratch_Master789 (March 5, 2020 23:32:14)

gor-dee
Scratcher
1000+ posts

"Spawning" a sprite in a random place a certain distance from another sprite

How about deliberately going to the object then moving away
go to [ object v]
point in direction (pick random (-180) to (180))
move (pick random (50) to (200)) steps //or whatever distance is appropriate
Scratch_Master789
Scratcher
7 posts

"Spawning" a sprite in a random place a certain distance from another sprite

I have resolved this issue but encountered another. Now it only “despawns” when it hits the sprite that is being defended, not when the mouse goes over it, despite the only difference in scripts is the name in the is touching block.

Edit: By this I mean, it disappears when I move my mouse over it but continues towards the sprite and only reappears when I move my mouse away.

Last edited by Scratch_Master789 (March 5, 2020 23:57:25)

codeman1044
Scratcher
1000+ posts

"Spawning" a sprite in a random place a certain distance from another sprite

It's best to share your project instead of describing what's happening, so we can see exactly what happens and take a look at your code to see what's causing it.
Scratch_Master789
Scratcher
7 posts

"Spawning" a sprite in a random place a certain distance from another sprite

I have managed to solve the problem, thanks anyway, If you wish to check it out, the link is here: https://scratch.mit.edu/projects/347394320
johopixar
Scratcher
7 posts

"Spawning" a sprite in a random place a certain distance from another sprite

when this button clicked
BenjaminGunzelman
Scratcher
1 post

"Spawning" a sprite in a random place a certain distance from another sprite

Gor-dee thanks helping me with my project!

Powered by DjangoBB