- Home /
Question by
htzprdcts · Aug 26, 2021 at 05:11 AM ·
positiontranslatepositioning
Move object with Translate on X axis (with mouse)
Hello guys! I have a small problem in my app and i hope anyone can help me. I like to move an object along X axis only, based by another object rotation. For example, i have a Line with specific rotation. And i want to move another object (name as: Tool) based on the Line rotation, only in one axis, where my pointer is. I have an incomplete code for this, but this moving the Tool not only the X axis and on Y axis too. How can i disable the Input.mouseposition.y in my code?
Tools_WallsMover.gameObject.SetActive(true); Tools_WallsMover.transform.localEulerAngles = new Vector3(0, 0, -selectedWallUI.GetWallAngle()); Tools_WallsMover.transform.position = new Vector3(transform.right.x * Input.mousePosition.x, transform.right.x * Input.mousePosition.y, 0); //Tools_WallsMover.transform.position = Input.mousePosition; Tools_WallsMover.transform.Translate(transform.right, Space.World);
If the problem is simply dont blame me, im not az experienced coder for this, but i guess the solution is close :D
Thank u guys!
Comment