- Home /
Question by
mdinizzz · Mar 20, 2012 at 07:58 PM ·
ioscontrollerjoystick
problems with virtual joystick for IOS
hello I'm having problems with dual joystick that comes in the mobile assests, I want my player to move in the Y and X, caught the reference in SideScrollControl so the player moves on the X axis, I implemented something
function Update ()
{
var = Vector3.zero movement;
/ / Apply joystick movement moves from
if (moveTouchPad.position.x> 0)
movement Vector3.right * = * forwardSpeed moveTouchPad.position.x;
else
movement Vector3.right * = * backwardSpeed moveTouchPad.position.x;
if (moveTouchPad.position.y> 0)
movement Vector3.up * = * forwardSpeed moveTouchPad.position.y;
else
movement Vector3.up * = * backwardSpeed moveTouchPad.position.y;
so that the player walks on the Y axis so, I need the player to walk on the X axis and Y axis. help please
Comment
function Update() { var movement = Vector3.zero;
// Apply movement from move joystick
if ( moveTouchPad.position.x > 0 )
movement = Vector3.right * forwardSpeed * moveTouchPad.position.x;
else
movement = Vector3.right * backwardSpeed * moveTouchPad.position.x;
if ( moveTouchPad.position.y > 0 )
movement = Vector3.up * forwardSpeed * moveTouchPad.position.y;
else
movement = Vector3.up * backwardSpeed * moveTouchPad.position.y;
movement *= Time.deltaTime;
// Actually move the character
character.$$anonymous$$ove( movement );
Actually you could hit the 'edit' button and edit/format your original post.
Answer by m4c0 · Mar 20, 2012 at 08:22 PM
You are replacing the "movement" instance at line 8 and 10. I guess you want something like:
if ( moveTouchPad.position.y > 0 )
movement += Vector3.up * forwardSpeed * moveTouchPad.position.y;
else
movement += Vector3.up * backwardSpeed * moveTouchPad.position.y;
O$$anonymous$$G ! I LOVE U DUDE !! THAN$$anonymous$$S !! ITS WOR$$anonymous$$SSSSSSSSSS UOUWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW