x


HOW TO MAKE A 2D OBJECT MOVE WITH TOUCH INPUT ON ANOTHER

hey ...so i m making a small 2d game for android for a project..but i have a problem..i a using orthello the free sprite manager...so the problem is i want to have 2 texture at two ends of my screen at bottom and touching them should make the character move left and right..so the orthello have OT.Touched syntax to use for that which is cool..but the problem is that i cant make the character move ....i tried using bool nd then getcomponent on another script to check if it is touched but that results in an error NullRefrenceException:object refrence not set...so i am asking is there any way to make it work...nd plz i m new so jst explain a little bit ..i will be glad if u do so...nd thanx for helping.. my code in the 2nd script is this

using UnityEngine;

using System.Collections;

public class movementtouch : MonoBehaviour {

public touchinput script;
public int touch; 





void Update () {
    script= GetComponent("touchinput") as touchinput;
    Debug.Log("1");
    script.touch1.Equals(touch);
    Debug.Log("2");

    if(touch==1)
    {
    Debug.Log("BEAR MOVE");
    }


}

}

more ▼

asked May 30, 2012 at 09:23 AM

shaanbhaya gravatar image

shaanbhaya
1 16 12 14

I'm trying to do something similar. Could you give me the code you finally used? Thanks!

Jul 25, 2012 at 02:12 PM rfernandezmir
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
more ▼

answered Jul 25, 2012 at 02:28 PM

alucardj gravatar image

alucardj
28.5k 164 1035 197

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1505
x1100
x920
x73

asked: May 30, 2012 at 09:23 AM

Seen: 5032 times

Last Updated: Nov 09, 2012 at 05:15 AM