Button UI Moves Both Entities. How To Fix?

Just try it, and you’ll see the problem.

Link To Editor: PlayCanvas | HTML5 Game Engine

Clicking on all the buttons with my mouse doesn’t do anything?

What are the steps to reproduce this issue? Do you have a video to show? Which code file should we look at?

1 Like

Nevermind: https://playcanvas.com/editor/code/667901?tabs=28421359

Your variables are global to the whole application rather than scoped to the instance of the script:

var Dt;
var vec3 = pc.Vec3;

var run = false;
var jump = false;

var joystickX = null;
var joystickY = null;
var joyTime = 0;
var joyTimer = false;

This means that both UI controllers are changing the same set of variables.

1 Like

Forgot to include it only works with touch controls. I was in a rush when writing this post.