init
This commit is contained in:
commit
bd5b1556ff
269 changed files with 6249829 additions and 0 deletions
29
Assets/Scripts/Enemies/Goomba.cs
Normal file
29
Assets/Scripts/Enemies/Goomba.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Goomba : MonoBehaviour{
|
||||
|
||||
public float speed;
|
||||
public float maxSpeed;
|
||||
|
||||
Rigidbody2D rb2d;
|
||||
|
||||
bool canMove;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
void OnBecameVisible(){
|
||||
canMove = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
rb2d.AddForce(Vector2.left * speed);
|
||||
float limitedSpeed = Mathf.Clamp(rb2d.velocity.x, -maxSpeed, maxSpeed);
|
||||
rb2d.velocity = new Vector2(limitedSpeed, rb2d.velocity.y);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue