How to insert and offset on movement in the direction of he object is facing?
Hi,
I'm making a game that the object is moved with one finger and can be rotated using two fingers.
For making the movement I simply using
if (Input.touchCount > 0){
theTouch = Input.GetTouch(0);
if(theTouch.phase == TouchPhase.Moved){
Vector2 clickPosition = Camera.main.ScreenToWorldPoint(theTouch.position);
transform.position = clickPosition;
But, the result is not great for me, because the object stays covered by the finger, so I wish to make a little offset, só the finger stays on unit in front of the direction of object.
I tried using
Vector2 clickPosition2 = transform.InverseTransformPoint(clickPosition);
and setting the
transform.localPosition = clickPosition2 + offsett;
but the object stays teleporting in different places on the screen (maybe because it it's making a circular reference?)
What should i Do?
The full code is available here: https://github.com/luizbalestreri/Archer/blob/main/Assets/Scripts/ArrowString.cs
Your answer
Follow this Question
Related Questions
Code help with mobile touch drag 3D Top Down 0 Answers
Touch to move and drag to rotate object 2 Answers
iOS moving up and down question ( code problem ) 0 Answers
Bugs on move in air(falling); 0 Answers