I got an adventure game where there are cars driving on the road behind your house. I am trying to make the car randomly choose between directions when it comes to an intersection. I’m using a variable for directions and a math block that chooses a random number between the two directions you can move. The problem is that the car doesn’t change directions. It just goes straight forward. So it would be nice if someone could help
Here’s the game
scene.onOverlapTile(SpriteKind.Player, assets.tile"Tile of choice"
, function (sprite, location) {
if (Math.percentChance(50)) {
mySprite.vx = 0
mySprite.vy = -100
} else {
mySprite.vx = 100
mySprite.vy = 0
}
})
Thanks! I just had to wait for 7 months before I got any help with this. And btw im coding in blocks so that doesn’t really help me. Thanks anyway.
and “AI” is not a good word to use for this
its more like “random Direction” no neural network needed
This works for your code
If ever you need more help come