I've actually been working on trying to figure that out myself. You want an enemy to jump to the player's platform right?
I know the first thing to do would be setting the actor to "Receive events out of view -> no"
As I said, I'm having problems with this myself, but here is what I have so far.
- Code: Select all
if(yvelocity>=5)
{
P2Canjump=0;
}
if (yvelocity<14)
{
yvelocity+=gravity*2;
}
//------------------------------------------------------------------->
if(Player_State==1)
{
if(x<=player.x-15)//-----------------------Stand------->
{
P2dir=1;
}
if(x>=player.x+15)
{
P2dir=-1;
}
if(x<=player.x-50)//--------------------------Walk------->
{
P2dir=2; x+=speed
}
if(x>=player.x+50)
{
P2dir=-2; x-=speed;
}
if(player.y<y-100&&P2Canjump==1)
{
yvelocity-=jump;
P2Canjump=0;
if(P2dir==2||P2dir==1)
{
xvelocity=speed;
}
if(P2dir==-2||P2dir==-1)
{
xvelocity=-speed;
}
}
}
This won't work unless you add the proper variables.
What it does, is if the player is to the left and higher, the enemy will jump left.
Same the other way around.
I still need to figure out how to make an actor choose the nearest platform (maybe a distance function?)
Anyways, hope it helps at least a little.