Hi all,
I am at a loss as to how to fix this problem. Seems like i’ve tried everything. Regardless of what I do when the mouse is clicked force will be added to my player object so that it move to the top right of the screen regardless of where the mouse is positioned.
function FixedUpdate () {
mousePos = Input.mousePosition;
mousePos.z = 0;
mouseDir = mousePos - gameObject.transform.position;
mouseDir = mouseDir.normalized;
if (controlScheme == 0)
{
rigidbody.AddForce((mouseDir) * accelSpeed3D);
}
//Mouse based movement
if (Input.GetMouseButton(0) && PlayerCollision.playerCollisionEvent == false && controlScheme == 0)
{
if (accelSpeed3D <= maxSpeed)
{
accelSpeed3D += accelerationAdd * Time.deltaTime;
}
}
else
{
if (accelSpeed3D >= driftSpeed)
{
accelSpeed3D -= accelerationSubtract * Time.deltaTime;
}
}
}
I know for a fact that the mouse based movement stuff is working properly (as this works with an alternate control scheme), so I’m guessing there is something wrong the direction between the player and the mouse position (mouseDir).
Please help!!