Hello everyone!
As the title implies, I was wondering as to how I might manage to have an object pathfind to another instance of itself, with said instance possibly travelling to the original too.
Thank you!
Hello everyone!
As the title implies, I was wondering as to how I might manage to have an object pathfind to another instance of itself, with said instance possibly travelling to the original too.
Thank you!
Hi - you can save the destination to a scene variable or attach another object to it. You need to give them all a unique number id.
pathfinding enemy id number 1 to number 99
pick all enemy (might need this - depending on your events)
enemy id=99 then do - save enemy x and y to scene vars (update this each frame if its moving about
(if there’s loads then you might need Enemyx[enemy.id] and Enemyy[enemy.id]
then if enemy id=1 then move to Enemyx[99], Enemyy[99]
The other way- attaching another object
for each enemy when enemy created then create ‘fancy with feather’ change fancy_hat_with_feathers.id to enemy.id
then for each object change the position of fancy hat with feathers to the enemy position that has the same id
or you can use the sticker behaviour - but i don’t.
then you can refer enemy with id 1 and move it to fancy hat with feathers with id 99
Would I be able to have the instance selected at random, and have said instance moving? It’s required for my game.
You want random Enemy to move to random Enemy
Condition
Pick Random Enemy
Action
Change variable TempX set to Enemy.CenterX()
Change variable TempY set to Enemy.CenterY()
Condition
Pick random Enemy
Action
Change Enemy variable TargetX set to TempX
Change Enemy variable TargetY set to TempY
This is bare bones of what you need
You will also need to limit it so you don’t spam it
Compare in 2nd event if Enemy.TargetX and Y does not equal Enemy.CenterX and Y
So Enemy don’t try to go to itself
And if it is then force 2nd event to run again
you can use ‘pick a random object’ for that -
or pick random id RandomInRange(1,numberofobjects)
Hello again!
The game is procedurally generated; how would I go about assigning IDs to each individual cow upon the generation of a new world?
Are you culling and regenerating objects based on distance from player? If so you need to store the world in an array. And there’s lots of different ways to do that. if not use a scene structure of number variables and as you create objects then - add one to the variable. objects.cow add 1 and set cow.id to objects.cow