two guitexture that do not work together

Posted by London2423 on Game Development See other posts from Game Development or by London2423
Published on 2014-06-12T14:58:29Z Indexed on 2014/06/12 21:41 UTC
Read the original article Hit count: 215

Filed under:
|
|

I have two GUITexture that move left and right a cube. Is pretty strange but together they don't work. If I activate only one it works. To be more specific: If I have the left GUItexture alone in the game the cube move left. If I have the right GUITexture activated alone the cube move right. Seems all fine I thought but If I have both of them the cube move only right and not left. Where is the mistake?

Here is the code inside the GameObject cube for Right move

void OnMousedown ()
{
    transform.position += Vector3.right * Time.deltaTime;
}

For Left move

void OnMousedown ()
{
    transform.position += Vector3.left * Time.deltaTime;
}

And this is the left GUITexture code

//move the cube left
Cube.GetComponent<Left> ().enabled = true;
left.transform.position += Vector3.left * Time.deltaTime;

This is the right GUITexture

//move the cube right
Cube.GetComponent<Left> ().enabled = true;
right.transform.position += Vector3.right * Time.deltaTime;

What is the reason for this?
I hope someone can help me.

© Game Development or respective owner

Related posts about unity

Related posts about movement