LittleFox项目实战

dou66 / 2024-10-16 / 原文

建立TileMap作为地图
引入角色
给角色增加:circleCollider,rigidbody
新建一个脚本控制角色: PlayerCtrl

点击查看代码

发现一个问题:按空格键时有时无。 我决定对跳跃进行优化
点击查看代码
我不准备采用GetAxisRaw.因为这个只能-1,0,1.我想要实现移动时速度缓慢提升的效果

新建脚本CamereControl

点击查看代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraControl : MonoBehaviour
{
    public Transform player;//新建属性

    
    void Update()
    {
        transform.position =  new Vector3(player.position.x, 0 , -10f);//摄像头跟随角色移动
    }
}

增加CMmachine组件,给背景增加polygoncollider组件.

发现问题:青蛙不能按照程序行动
解决问题:unity的真实物理引擎导致的,我原本是boxcollider,应该修改为circleCollider