// Update is called once per frame void Update() { jellyfier.bounceSpeed = bounceSpeed.value; jellyfier.fallForce = fallForce.value; jellyfier.stiffness = stiffness.value; if (!jellyfier.GetComponent <Rigidbody>().useGravity) { jellyfier.transform.position = new Vector3(jellyfier.transform.position.x, height.value, jellyfier.transform.position.z); jellyfier.gameObject.transform.Rotate(Vector3.up, rotationSpeed.value); } bounceSpeedValue.text = bounceSpeed.value.ToString(); rotationSpeedValue.text = rotationSpeed.value.ToString(); fallForceValue.text = fallForce.value.ToString(); stiffnessValue.text = stiffness.value.ToString(); pressureValue.text = pressure.value.ToString(); heightValue.text = jellyfier.transform.position.y.ToString(); if (Input.GetMouseButton(0)) { RaycastHit hit; Ray ray = cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject == jellyfier.gameObject) { jellyfier.ApplyPressureToPoint(hit.point, pressure.value); } } } }
private void Update() { if (Input.GetMouseButton(0)) { mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); //We need to check if we are clicking on a mesh we can deform if (Physics.Raycast(mouseRay, out raycastHit)) { Jellyfier jellyfier = raycastHit.collider.GetComponent <Jellyfier>(); if (jellyfier != null) { Vector3 inputPoint = raycastHit.point + (raycastHit.normal * pressureOffset); jellyfier.ApplyPressureToPoint(inputPoint, pressureForce); } } } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Transform selection = hit.transform; Jellyfier selectionJellyfier = selection.GetComponent <Jellyfier>(); if (selectionJellyfier != null) { selectionJellyfier.ApplyPressureToPoint(selection.position, force); GameObject obj = Instantiate(new GameObject(selection.position.ToString())); obj.transform.position = selection.position; } } } }