让青蛙能左右移动,原理是给青蛙添加看不见的空物体,空物体带有位置坐标。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class frog_move : MonoBehaviour
{
Transform leftpoint, rightpoint;
Rigidbody2D rd;
bool faceleft = true;
// Use this for initialization
void Start ()
{
rd = GetComponent<Rigidbody2D>();
leftpoint= transform.GetChild(0);
rightpoint = transform.GetChild(1);
transform.DetachChildren();
}
// Update is called once per frame
void Update ()
{
Move();
}
private void