I have gameobject buttons parented under a camera, my main player view. My camera should jump when one button, a gameobject, not a ui, is touched. It doesn't, however.
![alt text][1]
[1]: /storage/temp/50440-screenshot2.png
My script;
#pragma strict
private var JumpH = 8;
// Jump Hieght 8 units
private var IsFalling = false;
// Is not falling start
var particle : GameObject;
function Update ()
{
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
var ray = Camera.main.ScreenPointToRay (touch.position);
if (Physics.Raycast (ray)) {
//ad effects here
GetComponent.().velocity.y = JumpH;
IsFalling = true;
}
}
}
}
When I drag the script into camera, the script works as expected. (My camera and children jump when the ios screen is touched.) However, when I drag the script into one of the children (jump-key3), nothing happens. Tagging the button maincamera does nothing. If anyone could help, I would really appreciate it. I'm a newbie, so please don't get frustrated if I said anything dumb. Thanks!
↧