float playerX;
float playerZ;
float chairX;
float chairZ;
void OnStart()
{
AddEntityCollideCallback("Player", "test_area", "TestFunction", false, 1);
}
void TestFunction(string &in asParent, string &in asChild, int alState)
{
TimerPushLoop("timer_Chair");
}
void TimerPushLoop(string &in asTimer)
{
AddTimer(asTimer, 0.1f, "TimerPushLoop");
NudgeChairTowardsPlayer();
// Add some kind of break so that the chair doesn't follow you forever.
// Or perhaps don't. =)
}
void NudgeChairTowardsPlayer()
{
chairX = GetEntityPosX("chair");
chairZ = GetEntityPosZ("chair");
playerX = GetPlayerPosX();
playerZ = GetPlayerPosZ();
float playerXinRelationToChair = playerX - chairX;
float playerZinRelationToChair = playerZ - chairZ;
float forceMultiplier = 500;
AddPropForce("chair", playerXinRelationToChair * forceMultiplier, 0.0f, playerZinRelationToChair * forceMultiplier, "World");
}