so what I have is a script that calculates the angle from the player to the mouse. It works just fine. Right is 0/360, up is 90, left is 180, down is 270.
I wanted to take that angle and use it with addforce to sort of make the character jump at the mouse… Nothing seems to be working.
v3Pos = Input.mousePosition;
v3Pos.z = (playerObject.transform.position.z - cameraObject.transform.position.z);
v3Pos = cameraObject.ScreenToWorldPoint(v3Pos);
v3Pos = v3Pos - playerObject.transform.position;
jumpRotation = Mathf.Atan2 (v3Pos.y, v3Pos.x) * Mathf.Rad2Deg;
if (Input.GetMouseButtonUp(0))
{
playerObject.AddForce(dir * force);;
}
I’m returning an error:
Assets/PlayerMover.js(21,30): BCE0023: No appropriate version of ‘UnityEngine.Rigidbody.AddForce’ for the argument list ‘(int)’ was found.
Please help.
What are the types of dir and force? I suppose the error is in the if statement (line 21 in your full file)?
– Rahazan