- Home /
Question by
Golden_Gamer · Feb 06, 2018 at 01:16 AM ·
c#transformvector3mousepositionoffset
MousePosition Offset
Ok, so I have this code and its suppose to move a trigger to the position of where you click and it kind of does that. It moves the trigger alright and I fixed the problem with the Y but I don't know how to fix the x and z because there just completely off from where its suppose to be.
Vector3 MousePos;
public int TapDamage = 10;
Vector3 StartPos;
Vector3 Temp;
private void Start()
{
StartPos = gameObject.transform.position;
}
void MovingClickBox()
{
if (Input.GetMouseButtonDown(0) == true)
{
MousePos = Input.mousePosition;
gameObject.transform.position = MousePos;
Temp = gameObject.transform.position;
Temp.y = 1;
gameObject.transform.position = Temp;
}
}
private void FixedUpdate()
{
MovingClickBox();
}
}
Comment
Your answer
Follow this Question
Related Questions
Locking gameobject to rotating floor 0 Answers
Problem with C# "if" statement? 2 Answers
Change size of an object up to a limit 2 Answers
Check y transform. Or limit(stop). 0 Answers
placing an object to it's initital position after picked up. 0 Answers