- Home /
Touch to turn wheelcolllider.steerAngle with limits
So I'm pretty stumped on how to get this totally perfect for the iPhone. Obviously with a keyboard you can just do FrontWheel.steerAngle = value * Input.GetAxis("Horizontal");
However I'm trying to work out how I can apply the same logic with touch. My touchright button is a guitexture, and works fine as below.
for (var touch: Touch in Input.touches)
{
// Turn Right
if(touch.phase == TouchPhase.Stationary && turnRightButton.HitTest (touch.position)){
TouchRightCount= 1;
}
else if(touch.phase == TouchPhase.Ended && turnRightButton.HitTest){
TouchRightCount= 0;
}
}
What would I need to do in order to get the same results as desktop onto iphone?
Help appreciated!
Answer by azmat786n · Dec 03, 2012 at 07:05 PM
var strAngle : Ray = mainCam.ScreenPointToRay(Input.mousePosition);
var wheel:WheelCollider;
var moveSpeed:float = 10;
function Update() {
wheel.steerAngle = strAngle.origin.x * moveSpeed * Time.deltaTime;
}
yes this is for mobile devices you can check it out the mouse position you can use for touch but make Ray and screen point like above script..
hope this is helpful
and kindly when you satisfy from any answer please give rate up :)
Its not what I'm after. I'm after as above, that when a certain guitexture is pressed, it will steer both wheel colliders (left and right) to the corresponding left or right gui texture.
you want to control with gui buttons..? left and right.?
GUI textures left and right, and so the steer angle resets back to center upon lifting off a texture.
Appreciate any help.
Your answer
Follow this Question
Related Questions
How to add in iphone controls? 1 Answer
Why is there so little support for Virtual D-pads? 3 Answers
How to change my game into an ios game 1 Answer
RPG style controls for iOS/Android 0 Answers
iPhone joystick? 0 Answers