Hello everyone, can anyone help me convert a custom interaction?
I'm experimenting to use a cube as an interaction other than the Input.mousePosition of ObiParticlePicker.cs, but i'm having trouble customizing it.
My idea is, by using a boolean variable as a trigger for grabbing the closest particle of the obi cloth if true and release the grabbing if false, a cube must have its own forward raycasting, than using the input.mousePosition.
I'm currently experimenting how for 3-days, but it seems I'm stuck.
These line of code are the one I am currently having trouble with.
I'm experimenting to use a cube as an interaction other than the Input.mousePosition of ObiParticlePicker.cs, but i'm having trouble customizing it.
My idea is, by using a boolean variable as a trigger for grabbing the closest particle of the obi cloth if true and release the grabbing if false, a cube must have its own forward raycasting, than using the input.mousePosition.
I'm currently experimenting how for 3-days, but it seems I'm stuck.
These line of code are the one I am currently having trouble with.
Code:
// Drag:
Vector3 mouseDelta = Input.mousePosition - lastMousePos;
if (mouseDelta.magnitude > 0.01f && OnParticleDragged != null)
{
Vector3 worldPosition = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, pickedParticleDepth));
OnParticleDragged.Invoke(new ParticlePickEventArgs(pickedParticleIndex,worldPosition));
}
else if (OnParticleHeld != null)
{
Vector3 worldPosition = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, pickedParticleDepth));
OnParticleHeld.Invoke(new ParticlePickEventArgs(pickedParticleIndex,worldPosition));
}
// Release:
if (Input.GetMouseButtonUp(0))
{
if (OnParticleReleased != null)
{
Vector3 worldPosition = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, pickedParticleDepth));
OnParticleReleased.Invoke(new ParticlePickEventArgs(pickedParticleIndex,worldPosition));
}
pickedParticleIndex = -1;
}