Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

I need help with click to move

$
0
0
this is my my script first of all: void Update() { if((grounded || !doubleJump) && Input.GetMouseButtonDown(0)) { target = Camera.main.ScreenToWorldPoint (Input.mousePosition); anim.SetBool ("Ground", false); GetComponent().AddForce(new Vector2(0, jumpForce)); target.z = transform.position.z; if (target.x <= target.z) { transform.localScale = new Vector3 (-1,1,1); } else if (target.x >= target.z) { transform.localScale = new Vector3 (1,1,1); } } transform.position = Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime); I added Rigidbody 2D to my player fish and set the gravity 0.2 so it's falling down real slowly. However, when I click on the fish it remains still for 2 seconds prior to falling down. I want to make it possible so that when the player clicks on the fish, the fish move upwards slowly. Clicking elsewhere works fine cause the fish swims to where i clicked. Clicking on the fish freezes it in that position for 2 seconds then falls slowly. so how do i fix the freeze, cause i want my fish to constantly moving.

Viewing all articles
Browse latest Browse all 1264

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>