- Home /
moving 2 walls in opposite with scaling the ground ,moving walls with opposite position and scaling the ground and roof
i am trying to build something like 3d home design and i am trying to put the script , but it is not working , please help i want to move opposite position of 2 walls with ground and roof scaling the same size , using mouse . and one wall witch is the back wall , scaling with roof and ground . i have used this code to move 1 wall per time:
private Vector3 screenPoint;
private Vector3 offset;
void OnMouseDown(){
screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, 0, screenPoint.z));
}
void OnMouseDrag(){
Vector3 cursorPoint = new Vector3(Input.mousePosition.x, 0, screenPoint.z);
Vector3 cursorPosition = Camera.main.ScreenToWorldPoint(cursorPoint) + offset;
transform.position = cursorPosition;
}
Comment
Your answer