0

I am struggling in problem that convert world position in local position. i am using iTween plugin in unity. And there is an argument of position in iTween which is take world position and but i want to use local position in pixel to move the object in iTween. I tried with transform.TransformPoint(new Vector3(0,0,0) i don't thing it is working according to pixel position.

like this example:

iTween.MoveTo(gameObject,iTween.Hash("position",new Vector(0,0,0) , "time" ,.6, "easetype" ,"easeincubic"));

the argument of position iTween take in World position but i want to convert in pixel position. Like i pass new Vector(450,50,0);

your help will be appreciated.

Pawan Chaurasiya
  • 881
  • 2
  • 16
  • 30

3 Answers3

4

remember to add: "islocal", true parameter in iTween.Hash

Pawan Chaurasiya
  • 881
  • 2
  • 16
  • 30
1

You can try to use Camera.current.WorldToScreenPoint(Vector3 vector) which returns a Vector3 with x and y in camera space, meaning between values between 0 and 1.

By multipling those values with Screen.width or Screen.height would give you the position in pixel.

tschm
  • 26
  • 5
1

"islocal' = true is not working properly in moveto function. There is another solution.

Here is my code :

iTween.MoveTo(gameObject,iTween.Hash("position",Target,"time",_Duration,"delay",_Delay,"easetype",_eEaseType,"islocal",true,"looptype",_eLoop));
Pawan Chaurasiya
  • 881
  • 2
  • 16
  • 30
  • iTween.MoveTo(gameObject, iTween.Hash("position", Target , "time", _Duration, "islocal", true, "easetype", iTween.EaseType.linear)); – Pawan Chaurasiya Jun 23 '15 at 12:21