init
This commit is contained in:
commit
9afd57306d
323 changed files with 204673 additions and 0 deletions
35
Assets/Scripts/Game12/Game12Paddle.cs
Normal file
35
Assets/Scripts/Game12/Game12Paddle.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Game12Paddle : MonoBehaviour{
|
||||
|
||||
public float speed;
|
||||
public Rigidbody2D rb1;
|
||||
public Rigidbody2D rb2;
|
||||
|
||||
float movement = 0;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (Input.GetKeyDown(KeyCode.Space)){
|
||||
if(movement == 1){
|
||||
movement = -1;
|
||||
}else if(movement == -1){
|
||||
movement = 1;
|
||||
}else if(movement == 0){
|
||||
movement = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate(){
|
||||
rb1.velocity = new Vector2(movement * speed, rb1.velocity.y);
|
||||
rb2.velocity = new Vector2(movement * speed, rb2.velocity.y);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue