Hi guys, I need a little help with moving from unity to unity iphone. I have a script that moves a cannon barrel along just the 1 axis. Works great in normal unity.
var turnSpeed = 5;
var moveSpeed = 5;
private var y : float;
function Update ()
{
// check to see if the W or S key is being pressed.
y = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
// Move the character forwards or backwards
transform.Rotate(y, 0, 0);
}
I want to just use two different OnGUI buttons to move it up or down.
I made a nice fire button earlier today that works well using OnGUI.
Here it is for anyone else who needs it. (the velocity is controlled via a slider bar).
var mypeepsPrefab : Rigidbody;
var throwClip : AudioClip;
var reloadTime = 0.5;
static var Count = 50;
private var LastShot = -10.0;
private var fired : boolean = false;
function OnGUI() {
if (GUI.Button(Rect(Screen.width-75, Screen.height-70,50,50),""))
fired = true;
}
function Update () {
if (fired (Time.time > reloadTime + LastShot Count > 0)) {
fired = false;
var peeps : Rigidbody = Instantiate(mypeepsPrefab,
transform.position, transform.rotation);
peeps.velocity = transform.TransformDirection(Vector3
(0,0,SliderBar.vScrollbarValue));
Physics.IgnoreCollision(peeps.collider,
transform.root.collider);
audio.PlayOneShot(throwClip);
LastShot = Time.time;
Count--;
}
}
So any ideas how to convert the code at the very top using OnGUI into unity iphone much appreciated ![]()