hey guys,
new to unity and programming.
the function I want to realize is like:
click A(startpoint) , right click B(endpoint), instantiate a particle system from A to B.
its not finish, cause I know there are many logic problems here, can you guys give me some hint on how i can make this work?
also,why i can’t use startpoint to assign a value to flowClone.transform.position?
Thanks!
void connection()
{
Vector3 startpoint;
Vector3 endpoint;
ParticleSystem flowClone;
bool startpointget;
bool endpointget;
if (Input.GetMouseButton(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
startpoint = hit.collider.transform.position;
}
}
if (Input.GetMouseButton(1))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
endpoint = hit.collider.transform.position;
}
}
flowClone = Instantiate(flow, Vector3.zero, Quaternion.identity) as ParticleSystem;
flowClone.transform.position = startpoint;
}