Unity help code keeps coming back with a error
Feb 13, 2017 at 4:22pm UTC
Hello,
somehow my code keeps getting a error in Unity. I'm a newbie in C++ so I have tried some alternatives and it didn't work. So if anybody can help me, I would be grateful. The use of this code is that I can scale a object with touch on a smartphone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
using UnityEngine;
using System.Collections;
public float (defaultScaleX , defaultScaleY , defaultScaleZ)
public float (currentScaleX, currentScaleY , currentScaleZ)
public GameObject (mBundleInstance = null)
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved){
Vector2touchDeltaPosition = Input.GetTouch(0).deltaPosition;
//Debug.Log( mBundleInstance.transform.rotation.y + ":"+touchDeltaPosition.x );
mBundleInstance.transform.Rotate(Vector3.up * -touchDeltaPosition.x * Time.deltaTime * rotationSpeed);
}
if (Input.touchCount == 2){
Touchtouch0 = Input.GetTouch(0);
Touchtouch1 = Input.GetTouch(1);
if (touch0.phase == TouchPhase.Moved && touch1.phase == TouchPhase.Moved){
Vector2prevDist = (touch0.position - touch0.deltaPosition) - (touch1.position - touch1.deltaPosition);
Vector2curDist = touch0.position - touch1.position;
floatdelta = curDist.magnitude - prevDist.magnitude;
if (delta > 0){
if (defaultScaleX >= currentScaleX* 4){
}
elseif(defaultScaleX < currentScaleX - 0.1){
}
elseif(defaultScaleX >= currentScaleX){
defaultScaleX = defaultScaleX + 0.03f;
defaultScaleY = defaultScaleY + 0.03f;
defaultScaleZ = defaultScaleZ + 0.03f;
mBundleInstance.transform.localScale = newVector3(defaultScaleX,defaultScaleY,defaultScaleZ);
}
else {
defaultScaleX = defaultScaleX + 0.03f;
defaultScaleY = defaultScaleY + 0.03f;
defaultScaleZ = defaultScaleZ + 0.03f;
mBundleInstance.transform.localScale = newVector3(defaultScaleX,defaultScaleY,defaultScaleZ);
}
}
elseif(delta < 0){
if (defaultScaleX <= currentScaleX){
}
elseif(defaultScaleX > currentScaleX){
defaultScaleX = defaultScaleX - 0.03f;
defaultScaleY = defaultScaleY - 0.03f;
defaultScaleZ = defaultScaleZ - 0.03f;
mBundleInstance.transform.localScale = newVector3(defaultScaleX,defaultScaleY,defaultScaleZ);
}
}
}
}
Topic archived. No new replies allowed.