hello all,
This is my first post, for Unity iphone
I am not much of the programming background, but still learning its aspects by using javascript mainly.
I am stuck with a thing like i want to move the game Object i created as per the mouse position click i am doing.
example like as how we play the smash base game, the cursor can act as a game object or when we click the object we want to appear, Appears at the position we clicked like hammer splashing on different areas of the screen.
What i have done is i have created the 3d plane with grass texture and i have put the small craters there (duplicated manner). And the game character appears from the craters, which is slamned or smashed by the cursor position like it hits at the right time at the face of the character the hit is counted.
here is the script that i have placed under the raycast, here the hitting and all parts and that game character interaction is working fine but the other game object is moving to some other place in the screen area, or you can just help me out the proper way to set it.
function Update ()
{
// setting positioning
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast(ray, hit, 100))
{
if(!Input.GetMouseButtonDown(0))
return;
animation.Play();
var mPos = Input.mousePosition;
print(mPos);
transform.position = mPos;
//transform.Translate(mPos);
}
}
transform.position = mPos;
OR i am also used with this one
transform.Translate(mPos);
both are causing the different effects but not the one i want in proper manner.
Hope i am able to express the situation in a right manner. Looking for some help in this regards
thanks