简体   繁体   中英

Unity Mouse Reseting Position Problem How Do I fix This?

video < everytime I click the button I want the dots to pick up the currentposition of the mouse and start moving from there and not the position I just clicked which makes it teleport how do I fix this problem?


    void Update()
    {
   
        if (dotss == true)
        {
            Vector2 mousepos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 bowpos = transform.position;
            direction = mousepos - bowpos;
            for (int i = 0; i < Points.Length; i++)
            {
                Points[i].transform.position = Pointposition(i * 0.1f);
            }
        }

    }



    Vector2 Pointposition(float t)
    {
        Vector2 currentPointpos = (Vector2)transform.position + (direction.normalized * force * t) + 0.5f * Physics2D.gravity * (t * t);
        return currentPointpos;
    }





We need to know what function the button press calls when clicked, but it really should be as simple as setting dotss to true on button click. My guess is that something is disabling dotss, because your code looks like it should run properly otherwise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM