I already explained this to you on Discord.
I provided you a code similar to this:
lcl wrote:- Code: Select all
double xx = player_collider.x - width / 2;
double yy = player_collider.y - height / 1.5;
double speed = distance(x, y, xx, yy) / 10.0;
MoveTo("Event Actor", xx, yy, speed, "Game Center", "");
And then you said that the view jitters around occasionally.
And then I told you what to do:
lcl wrote:Just add an if condition and make the MoveTo only execute if the view's distance from the (xx, yy) is greater than some limit value
And then you never returned to me on discord with your problem and instead seemingly proceeded to create this new topic. I was trying to help you already, and you were midway solving your problem so why do you start with the same question from the beginning again somewhere else?
Anyway, here's what I meant with my last remark:
- Code: Select all
double xx = player_collider.x - width / 2;
double yy = player_collider.y - height / 1.5;
double speed = distance(x, y, xx, yy) / 10.0;
if (distance(x, y, xx, yy) > 5) // This
{
MoveTo("Event Actor", xx, yy, speed, "Game Center", "");
}
The condition marked with a comment is new. It's meant to stop the view from moving if it already is very close to the position where it should be. This stops the jittering. The jittering is caused by the view not being able to reach the
exact position of (xx, yy) and then vibrating around that position, desperately trying to reach it.
I hope this helps!