Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

how to make an enemy into a second player

$
0
0
i just began useing unity and i made a pong game in the game there is one player and one enemy ai, and i want to know how to make the enemy ai into a second player so it can be a 2 player game. here are the player and enemy scripts just in case you need them the enemy script void Update() { ballObj = GameObject.FindGameObjectWithTag("Ball"); if(ballObj != null) { targetPos = Vector3.Lerp(transform.position, ballObj.transform.position, Time.deltaTime * speed); playerPos = new Vector3(-20, Mathf.Clamp(targetPos.y, -13, 13), 0); transform.position = new Vector3(20, playerPos.y, 0); } } the player script void Update() { float yPos = transform.position.y + (Input.GetAxis("Vertical") * paddleSpeed); playerPos = new Vector3(-20, Mathf.Clamp(yPos, -11, 11), 0); transform.position = playerPos; }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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