【unity实战】使用旧输入系统Input Manager 写一个 2D 平台游戏玩家控制器——包括移动、跳跃、滑墙、蹬墙跳

最终效果

在这里插入图片描述

文章目录

  • 最终效果
  • 素材下载
    • 人物
    • 环境
  • 简单绘制环境
  • 角色移动跳跃
  • 视差和摄像机跟随效果
  • 奔跑动画切换
  • 跳跃动画,跳跃次数限制
  • 角色添加2d物理材质,防止角色粘在墙上
  • 如果角色移动时背景出现黑线条
    • 方法一
    • 方法二
  • 墙壁滑行
  • 实现角色滑墙不可以通过移动离开且不可翻转角色
  • 空中运动控制
  • 可变跳跃高度
  • 蹬墙跳
  • 完整代码
  • 源码
  • 完结

素材下载

人物

https://rvros.itch.io/animated-pixel-hero
在这里插入图片描述

环境

https://bardent.itch.io/the-bardent-asset-pack
在这里插入图片描述
https://brullov.itch.io/oak-woods
在这里插入图片描述

简单绘制环境

参考:【推荐100个unity插件之14】Unity2D TileMap的探究(最简单,最全面的TileMap使用介绍)
在这里插入图片描述

角色移动跳跃

新增PlayerController

public class PlayerController : MonoBehaviour
{
    private float movementInputDirection; // 水平输入方向
    private bool isFacingRight = true; // 玩家是否面向右侧
    private Rigidbody2D rb;
    public float movementSpeed = 10.0f; // 移动速度
    public float jumpForce = 16.0f; // 跳跃力度

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        CheckInput(); // 检查输入
        CheckMovementDirection();
    }

    private void FixedUpdate()
    {
        ApplyMovement(); // 应用移动
    }

    // 检查玩家面朝的方向
    private void CheckMovementDirection()
    {
        if (isFacingRight && movementInputDirection < 0)
        {
            Flip(); // 翻转角色
        }
        else if (!isFacingRight && movementInputDirection > 0)
        {
            Flip(); // 翻转角色
        }
    }

    // 检查输入
    private void CheckInput()
    {
        movementInputDirection = Input.GetAxisRaw("Horizontal"); // 获取水平输入
        if (Input.GetButtonDown("Jump"))
        {
            Jump(); // 如果按下跳跃键,则执行跳跃
        }
    }

    // 跳跃
    private void Jump()
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce); // 设置 y 方向的速度为跳跃力度
    }

    // 移动
    private void ApplyMovement()
    {
        rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 设置 x 方向的速度
    }

    // 翻转角色
    private void Flip()
    {
        isFacingRight = !isFacingRight; // 改变面向方向的标志
        transform.Rotate(0.0f, 180.0f, 0.0f); // 旋转角色
    }
}

配置
在这里插入图片描述
效果
在这里插入图片描述

视差和摄像机跟随效果

参考:【unity小技巧】Unity实现视差效果与无限地图

新增CameraController代码

public class CameraController : MonoBehaviour
{
    public Transform target;//玩家的位置
    public Transform farBackground, middleBackground, frontBackground;//远的背景和中间背景的位置
    private Vector2 lastPos;//最后一次的相机位置
    void Start()
    {
        lastPos = transform.position;//记录相机的初始位置
    }

    void Update()
    {
        //将相机的位置设置为玩家的位置,但限制在一定的垂直范围内
        //transform.position = new Vector3(target.position.x, target.position.y + 1f, transform.position.z);
        //计算相机在上一帧和当前帧之间移动的距离
        Vector2 amountToMove = new Vector2(transform.position.x - lastPos.x, transform.position.y - lastPos.y);
        //根据相机移动的距离,移动远背景和中间背景的位置
        farBackground.position += new Vector3(amountToMove.x, amountToMove.y, 0f);
        middleBackground.position += new Vector3(amountToMove.x * 0.9f, amountToMove.y, 0f);
        frontBackground.position += new Vector3(amountToMove.x * 0.5f, amountToMove.y, 0f);
        lastPos = transform.position;//更新最后一次的相机位置
    }
}

Map代码

public class Map : MonoBehaviour
{
    [Header("无限地图")]
    private GameObject mainCamera;//主摄像机对象
    private float mapwidth;//地图宽度
    private float totalwidth;//总地图宽度
    
    public int mapNums;//地图重复的次数
    void Start()
    {
        mainCamera = GameObject.FindGameObjectWithTag("MainCamera");//查找标签为"MainCamera'"的对象并赋值
        mapwidth = GetComponent<SpriteRenderer>().sprite.bounds.size.x;//通过SpriteRenderer获得图像宽度
        totalwidth = mapwidth * mapNums;//计算总地图宽度
    }

    void FixedUpdate()
    {
        Vector3 tempPosition = transform.position;//获取当前位置
        if (mainCamera.transform.position.x > transform.position.x + totalwidth / 2)
        {
            tempPosition.x += totalwidth;//将地图向右平移一个完整的地图宽度
            transform.position = tempPosition;//更新位置
        }
        else if (mainCamera.transform.position.x < transform.position.x - totalwidth / 2)
        {
            tempPosition.x -= totalwidth;//将地图向左平移一个完整的地图宽度
            transform.position = tempPosition;//更新位置
        }

    }
}

配置
在这里插入图片描述
在这里插入图片描述
效果
在这里插入图片描述

奔跑动画切换

动画配置
在这里插入图片描述

修改PlayerController

private void FixedUpdate()
{
    ApplyMovement(); // 应用移动
    UpdateStatus();
}

//判断状态 
private void UpdateStatus(){
    if(rb.velocity.x != 0){
        isRunning = true;
    }else{
        isRunning = false;
    }
}

//播放动画
private void UpdateAnimations(){
    animator.SetBool("isRunning", isRunning);
}

效果
在这里插入图片描述

跳跃动画,跳跃次数限制

配置跳跃动画
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
修改PlayerController

[Header("跳跃 地面检测")]
private float amountOfJumpsLeft;//当前可跳跃次数
private bool isGround;//是否是地面
private bool canJump;//能否跳跃
public int amountOfJumps = 1;//跳跃次数
public float groundCheckRadius;//地面检测距离
public Transform groundCheck;//地面检测点
public LayerMask whatIsGround;//地面检测图层


void Start()
{
    rb = GetComponent<Rigidbody2D>();
    animator = GetComponent<Animator>();
    amountOfJumpsLeft = amountOfJumps;
}

// 检查输入
private void CheckInput()
{
    movementInputDirection = Input.GetAxisRaw("Horizontal"); // 获取水平输入
    if (Input.GetButtonDown("Jump"))
    {
        Jump(); // 如果按下跳跃键,则执行跳跃
    }
}

// 跳跃
private void Jump()
{
    if (canJump)
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce); // 设置 y 方向的速度为跳跃力度
        amountOfJumpsLeft--;
    }
}

//判断能否跳跃
private void CheckIfCanJump()
{
    if (isGround && rb.velocity.y < 0)
    {
        amountOfJumpsLeft = amountOfJumps;
    }
    if (amountOfJumpsLeft <= 0)
    {
        canJump = false;
    }
    else
    {
        canJump = true;
    }
}

//播放动画
private void UpdateAnimations()
{
    animator.SetBool("isRunning", isRunning);
    animator.SetBool("isGround", isGround);
    animator.SetFloat("yVelocity", rb.velocity.y);
}

//检测
private void CheckSurroundings()
{
    //地面检测
    isGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
}

//视图显示检测范围
private void OnDrawGizmos()
{
    Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);
}

配置,这里配置了2段跳
在这里插入图片描述
记得配置地面图层为Ground
在这里插入图片描述
效果
在这里插入图片描述

角色添加2d物理材质,防止角色粘在墙上

在这里插入图片描述
修改摩檫力为0
在这里插入图片描述
配置
在这里插入图片描述
效果
在这里插入图片描述

如果角色移动时背景出现黑线条

方法一

添加材质
在这里插入图片描述
配置
在这里插入图片描述

方法二

我们创建了一个Sprite Atlas来将Spritesheet拖入其中
在这里插入图片描述
把你的瓦片素材拖入
在这里插入图片描述

墙壁滑行

配置滑墙动画
在这里插入图片描述

修改PlayerController

[Header("墙壁滑行")]
public float wallCheckDistance;//墙壁检测距离
public Transform wallCheck;//墙壁检测点
public float wallSlideSpeed;//墙壁滑行速度
private bool isTouchingWall;//是否接触墙壁
private bool isWallSliding;//是否正在墙壁滑行

// 移动
private void ApplyMovement()
{
    rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 设置 x 方向的速度
    
    //应用滑墙速度    
    if (isWallSliding)
    {
        if (rb.velocity.y < -wallSlideSpeed)
        {
            rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以应用墙壁滑行速度
        }
    }
}

//是否正在墙壁滑行
private void CheckIfWallSliding()
{
    if (isTouchingWall && !isGround && rb.velocity.y < 0)
    {
        isWallSliding = true;
    }
    else
    {
        isWallSliding = false;
    }
}

//播放动画
private void UpdateAnimations()
{
    animator.SetBool("isRunning", isRunning);
    animator.SetBool("isGround", isGround);
    animator.SetFloat("yVelocity", rb.velocity.y);
    animator.SetBool("isWallSliding", isWallSliding);
}

//检测
private void CheckSurroundings()
{
    //地面检测
    isGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);

    //墙面检测
    isTouchingWall = Physics2D.Raycast(wallCheck.position, transform.right, wallCheckDistance, whatIsGround);
}

//视图显示检测范围
private void OnDrawGizmos()
{
    Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);
    Gizmos.DrawLine(wallCheck.position, wallCheck.position + wallCheckDistance * Vector3.right);
}

配置
在这里插入图片描述
效果
在这里插入图片描述

实现角色滑墙不可以通过移动离开且不可翻转角色

// 移动
private void ApplyMovement()
{
    // 如果在地面上
    if (isGround)
    {
        rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 设置 x 方向的速度
    }

    //应用滑墙速度    
    if (isWallSliding)
    {
        if (rb.velocity.y < -wallSlideSpeed)
        {
            rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以应用墙壁滑行速度
        }
    }
}

// 翻转角色
private void Flip()
{
    if (!isWallSliding)
    {
        isFacingRight = !isFacingRight; // 改变面向方向的标志
        transform.Rotate(0.0f, 180.0f, 0.0f); // 旋转角色
    }
}

效果
在这里插入图片描述

空中运动控制

空气阻力和移动速度控制

public float movementForceInAir;//空气中的运动力
public float airDragMultiplier = 0.95f;//空气阻力

// 移动
private void ApplyMovement()
{
    // 如果在地面上
    if (isGround)
    {
        rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 设置 x 方向的速度
    }
    // 如果不在地面上且不是在墙壁滑行且有水平输入
    else if (!isGround && !isWallSliding && movementInputDirection != 0)
    {
        Vector2 forceToAdd = new Vector2(movementForceInAir * movementInputDirection, 0);// 在空中施加的力
        rb.AddForce(forceToAdd);// 添加力到刚体
        if (Mathf.Abs(rb.velocity.x) > movementSpeed)
        {
            rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y);// 限制水平速度
        }
    }
    // 如果不在地面上且不是在墙壁滑行且没有水平输入
    else if (!isGround && !isWallSliding && movementInputDirection == 0)
    {
        rb.velocity = new Vector2(rb.velocity.x * airDragMultiplier, rb.velocity.y);// 应用空气阻力
    }

    //应用滑墙速度    
    if (isWallSliding)
    {
        if (rb.velocity.y < -wallSlideSpeed)
        {
            rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以应用墙壁滑行速度
        }
    }
}

配置
在这里插入图片描述
效果
在这里插入图片描述

可变跳跃高度

长跳跃和短跳,长按和之前跳的和之前一样高

public float variableJumpHeightMultiplier = 0.5f;

 // 检查输入
private void CheckInput()
{
    movementInputDirection = Input.GetAxisRaw("Horizontal"); // 获取水平输入
    if (Input.GetButtonDown("Jump"))
    {
        Jump(); // 如果按下跳跃键,则执行跳跃
    }

	// 检测是否松开Jump
    if (Input.GetButtonUp("Jump"))
    {
        rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * variableJumpHeightMultiplier);
    }
}

效果
在这里插入图片描述

蹬墙跳

实现不输入,点击跳跃就从墙上跳下来,方向按键+跳跃控制左右蹬墙跳

[Header("蹬墙跳")]
public float wallHopForce; // 离开墙时的力
public float wallJumpForce; // 蹬墙跳时施加的力
public Vector2 wallHopDirection; // 离开墙时的方向向量
public Vector2 wallJumpDirection; // 蹬墙跳时的方向向量
private int facingDirection = 1; // 角色面向的方向,1右 -1左

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    animator = GetComponent<Animator>();
    amountOfJumpsLeft = amountOfJumps;
    
    //归一化向量,因为我们只要向量的方向,而不考虑长度
    wallHopDirection = wallHopDirection.normalized;
    wallJumpDirection = wallJumpDirection.normalized;
}

// 跳跃
private void Jump()
{
    // 如果可以跳跃并且不是在墙壁滑行状态下
    if (canJump && !isWallSliding)
    {
        rb.velocity = new Vector2(rb.velocity.x, jumpForce); // 设置 y 方向的速度为跳跃力度
        amountOfJumpsLeft--;
    }
    // 如果正在墙壁滑行且没有输入水平移动方向,并且可以跳跃
    else if(isWallSliding && movementInputDirection == 0 && canJump){
        isWallSliding = false;
        amountOfJumpsLeft--;
        // 计算添加的力量,使角色从墙壁上弹开
        Vector2 forceToAdd = new Vector2(wallHopForce * wallHopDirection.x * -facingDirection, wallHopForce * wallHopDirection.y);
        rb.AddForce(forceToAdd, ForceMode2D.Impulse);
    }
    // 如果正在墙壁滑行或者正在接触墙壁,并且有水平移动输入,并且可以跳跃
    else if((isWallSliding || isTouchingWall) && movementInputDirection != 0 && canJump){
        isWallSliding = false;
        amountOfJumpsLeft --;
        // 计算添加的力量,使角色从墙壁上跳跃
        Vector2 forceToAdd = new Vector2(wallHopForce * wallHopDirection.x * movementInputDirection, wallJumpForce * wallJumpDirection.y);
        rb.AddForce(forceToAdd, ForceMode2D.Impulse);
    }
}

 //判断能否跳跃
private void CheckIfCanJump()
{
    if ((isGround && rb.velocity.y < 0) || isWallSliding)
    {
        amountOfJumpsLeft = amountOfJumps;
    }

    if (amountOfJumpsLeft <= 0)
    {
        canJump = false;
    }
    else
    {
        canJump = true;
    }
}

// 翻转角色
private void Flip()
{
    if (!isWallSliding)
    {
        facingDirection *= -1;
        isFacingRight = !isFacingRight; // 改变面向方向的标志
        transform.Rotate(0.0f, 180.0f, 0.0f); // 旋转角色
    }
}

配置
在这里插入图片描述
运行效果
在这里插入图片描述

完整代码

using Unity.VisualScripting;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private float movementInputDirection; // 水平输入方向
    private bool isFacingRight = true; // 玩家是否面向右侧
    private Rigidbody2D rb;
    public float movementSpeed = 10.0f; // 移动速度
    public float jumpForce = 16.0f; // 跳跃力度

    private Animator animator;

    [Header("状态")]
    public bool isRunning;

    [Header("跳跃 地面检测")]

    public int amountOfJumps = 1;//跳跃次数
    public float groundCheckRadius;//地面检测距离
    public Transform groundCheck;//地面检测点
    public LayerMask whatIsGround;//地面检测图层
    private float amountOfJumpsLeft;//当前可跳跃次数
    private bool isGround;//是否是地面
    private bool canJump;//能否跳跃

    [Header("墙壁滑行")]
    public float wallCheckDistance;//墙壁检测距离
    public Transform wallCheck;//墙壁检测点
    public float wallSlideSpeed;//墙壁滑行速度
    public float movementForceInAir;//空气中的运动力
    public float airDragMultiplier = 0.95f;//空气阻力
    private bool isTouchingWall;//是否接触墙壁
    private bool isWallSliding;//是否正在墙壁滑行

    [Header("可变高度")]
    public float variableJumpHeightMultiplier = 0.5f;

    [Header("蹬墙跳")]
    public float wallHopForce; // 离开墙时的力
    public float wallJumpForce; // 蹬墙跳时施加的力
    public Vector2 wallHopDirection; // 离开墙时的方向向量
    public Vector2 wallJumpDirection; // 蹬墙跳时的方向向量
    private int facingDirection = 1; // 角色面向的方向,1右 -1左

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
        amountOfJumpsLeft = amountOfJumps;
        //归一化向量,因为我们只要向量的方向,而不考虑长度
        wallHopDirection = wallHopDirection.normalized;
        wallJumpDirection = wallJumpDirection.normalized;
    }

    void Update()
    {
        CheckInput(); // 检查输入
        CheckMovementDirection();
        UpdateAnimations();
        CheckIfCanJump();
        CheckIfWallSliding();
        CheckSurroundings();
    }

    private void FixedUpdate()
    {
        ApplyMovement(); // 应用移动
        UpdateStatus();
    }

    // 检查玩家面朝的方向
    private void CheckMovementDirection()
    {
        if (isFacingRight && movementInputDirection < 0)
        {
            Flip(); // 翻转角色
        }
        else if (!isFacingRight && movementInputDirection > 0)
        {
            Flip(); // 翻转角色
        }
    }

    // 检查输入
    private void CheckInput()
    {
        movementInputDirection = Input.GetAxisRaw("Horizontal"); // 获取水平输入
        if (Input.GetButtonDown("Jump"))
        {
            Jump(); // 如果按下跳跃键,则执行跳跃
        }
        
        if (Input.GetButtonUp("Jump"))
        {
            rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * variableJumpHeightMultiplier);
        }
    }

    // 移动
    private void ApplyMovement()
    {
        // 如果在地面上
        if (isGround)
        {
            rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 设置 x 方向的速度
        }
        // 如果不在地面上且不是在墙壁滑行且有水平输入
        else if (!isGround && !isWallSliding && movementInputDirection != 0)
        {
            Vector2 forceToAdd = new Vector2(movementForceInAir * movementInputDirection, 0);// 在空中施加的力
            rb.AddForce(forceToAdd);// 添加力到刚体
            if (Mathf.Abs(rb.velocity.x) > movementSpeed)
            {
                rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y);// 限制水平速度
            }
        }
        // 如果不在地面上且不是在墙壁滑行且没有水平输入
        else if (!isGround && !isWallSliding && movementInputDirection == 0)
        {
            rb.velocity = new Vector2(rb.velocity.x * airDragMultiplier, rb.velocity.y);// 应用空气阻力
        }

        // //应用滑墙速度    
        if (isWallSliding)
        {
            if (rb.velocity.y < -wallSlideSpeed)
            {
                rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以应用墙壁滑行速度
            }
        }
    }

    // 移动
    private void ApplyMovement()
    {
        if(!isGround && !isWallSliding && movementInputDirection == 0){
            rb.velocity = new Vector2(rb.velocity.x * airDragMultiplier, rb.velocity.y);// 应用空气阻力
        }else{
            rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 设置 x 方向的速度
        }

        //应用滑墙速度    
        if (isWallSliding)
        {
            if (rb.velocity.y < -wallSlideSpeed)
            {
                rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以应用墙壁滑行速度
            }
        }
    }

    //判断跑步状态 
    private void UpdateStatus(){
        if(rb.velocity.x != 0){
            isRunning = true;
        }else{
            isRunning = false;
        }
    }

    // 翻转角色
    private void Flip()
    {
        if (!isWallSliding)
        {
            facingDirection *= -1;
            isFacingRight = !isFacingRight; // 改变面向方向的标志
            transform.Rotate(0.0f, 180.0f, 0.0f); // 旋转角色
        }
    }

    //播放动画
    private void UpdateAnimations()
    {
        animator.SetBool("isRunning", isRunning);
        animator.SetBool("isGround", isGround);
        animator.SetFloat("yVelocity", rb.velocity.y);
        animator.SetBool("isWallSliding", isWallSliding);
    }

    //判断能否跳跃
    private void CheckIfCanJump()
    {
        if ((isGround && rb.velocity.y < 0) || isWallSliding)
        {
            amountOfJumpsLeft = amountOfJumps;
        }

        if (amountOfJumpsLeft <= 0)
        {
            canJump = false;
        }
        else
        {
            canJump = true;
        }
    }

    //检测
    private void CheckSurroundings()
    {
        //地面检测
        isGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);

        //墙面检测
        isTouchingWall = Physics2D.Raycast(wallCheck.position, transform.right, wallCheckDistance, whatIsGround);
    }

    //是否墙壁滑行
    private void CheckIfWallSliding()
    {
        if (isTouchingWall && !isGround && rb.velocity.y < 0)
        {
            isWallSliding = true;
        }
        else
        {
            isWallSliding = false;
        }
    }

    //视图显示检测范围
    private void OnDrawGizmos()
    {
        Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);
        Gizmos.DrawLine(wallCheck.position, wallCheck.position + wallCheckDistance * Vector3.right);
    }
}

源码

整理好了我会放上来

完结

赠人玫瑰,手有余香!如果文章内容对你有所帮助,请不要吝啬你的点赞评论和关注,以便我第一时间收到反馈,你的每一次支持都是我不断创作的最大动力。当然如果你发现了文章中存在错误或者有更好的解决方法,也欢迎评论私信告诉我哦!

好了,我是向宇,https://xiangyu.blog.csdn.net

一位在小公司默默奋斗的开发者,出于兴趣爱好,最近开始自学unity,闲暇之余,边学习边记录分享,站在巨人的肩膀上,通过学习前辈们的经验总是会给我很多帮助和启发!php是工作,unity是生活!如果你遇到任何问题,也欢迎你评论私信找我, 虽然有些问题我也不一定会,但是我会查阅各方资料,争取给出最好的建议,希望可以帮助更多想学编程的人,共勉~
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/765211.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

MySQL——事务ACID原则、脏读、不可重复读、幻读

什么是事务 要么都成功&#xff0c;要么都失败 一一一一一一一 1. SQL执行&#xff1a;A给B转账 A 1000 ---->200 B 200 2. SQL执行&#xff1a;B收到A的钱 A 800 B 400 一一一一一一一 将一组SQL放在一个批次中去执行~ 事务原则&#xff1a;ACI…

SolidWorks教育版:丰富的教学资源

在当今日新月异的工程教育领域中&#xff0c;一款强大的教学工具对于提高学生的学习效果和创新能力至关重要。SolidWorks教育版凭借其丰富的教学资源&#xff0c;不仅满足了教师的教学需求&#xff0c;也为学生提供了一个全方面、深入的学习平台。本文将深入探讨SolidWorks教育…

[DataWhale大模型应用开发]学习笔记1-尝试搭建向量数据库

1.词向量 1.定义 词向量&#xff08;Word Vector&#xff09;是将单词表示为向量形式的技术&#xff0c;是自然语言处理&#xff08;NLP&#xff09;中的一种常用方法。通过将单词转化为向量&#xff0c;计算机能够更好地理解和处理语言。简单来说&#xff0c;词向量就是将单…

Cocos制作抖音小游戏接入侧边栏复访接口实例

本篇文章主要讲解&#xff0c;使用cocos接入抖音小游戏侧边栏接口的实例教程。 日期&#xff1a;2024年7月1日 作者&#xff1a;任聪聪 教程实例&#xff1a;https://download.csdn.net/download/hj960511/89509196 下载后可直接导入运行 上传游戏后抖音预审不通过 注意&#x…

win10下安装PLSQL14连接Oracle数据库

问题背景 在使用Oracle开发过程中&#xff0c;经常会使用工具来连接数据库&#xff0c;方便查询、处理数据。其中有很多工具可以使用&#xff0c;比如dbeaver、plsql等。本文主要介绍在win10环境下&#xff0c;plsql14的安装步骤以及安装过程中遇到的一些问题。 安装步骤及问题…

TensorRT学习(二)TensorRT使用教程(Python版)

本文适合快速了解TensorRT使用的整体流程,具体细节还是建议参考TensorRT的官方文档。 加速原理: 加速原理比较复杂,它将会根据显卡来优化算子,以起到加速作用(如下图所示)。简单的来说,就是类似于你出一个公式1+1+1,而你的显卡支持乘法,直接给你把这个公式优化成了1*…

scikit-learn教程

scikit-learn&#xff08;通常简称为sklearn&#xff09;是Python中最受欢迎的机器学习库之一&#xff0c;它提供了各种监督和非监督学习算法的实现。下面是一个基本的教程&#xff0c;涵盖如何使用sklearn进行数据预处理、模型训练和评估。 1. 安装和导入包 首先确保安装了…

controller不同的后端路径对应vue前端传递数据发送请求的方式,vue请求参数 param 与data 如何对应后端参数

目录 案例一&#xff1a; 为什么使用post发送请求&#xff0c;参数依旧会被拼接带url上呢&#xff1f;这应该就是param 与data传参的区别。即param传参数参数会被拼接到url后&#xff0c;data会以请求体传递 补充&#xff1a;后端controller 参数上如果没写任何注解&#xff0c…

【附精彩文章合辑】为何选择TypeScript?转变的驱动力:Rust的魅力何在?

在探讨一个开发者团队耗时18个月从TypeScript转向Rust&#xff0c;并随后对TypeScript进行严厉批评的情境时&#xff0c;我们首先需要认识到&#xff0c;任何技术栈的选择与转换都是基于一系列复杂的考量&#xff0c;包括但不限于项目需求、性能瓶颈、团队技能、长期可维护性以…

VGPU的使用

&#xff08;作者&#xff1a;陈玓玏&#xff09; 开源项目&#xff0c;欢迎star哦&#xff0c;https://github.com/data-infra/cube-studio 训练AI模型以及部署模型推理服务时&#xff0c;GPU往往是必不可少的&#xff0c;但当我们机器上没有足够的GPU卡可使用时&#xf…

探索未来远程调试新纪元——《串口网口远程调试软件》:无缝连接,高效调试

文章目录 前言一、无缝连接&#xff0c;突破距离限制二、高效调试&#xff0c;提升工作效率三、安全可靠&#xff0c;保护数据安全四、用户友好&#xff0c;简化操作流程五、软件地址六、远程调试软件 七、基本操作1、订阅主题2、连接3、串口调试4、网口调试 八、软件地址结束语…

【问题记录】如何在xftp上查看隐藏文件。

显示隐藏的文件夹 用xftp连接到服务器后&#xff0c;发现有些隐藏的文件夹并未显示出来&#xff0c;通过以下配置&#xff0c;即可使隐藏的文件夹给显示出来。 1.点击菜单栏的"小齿轮"按钮&#xff1a; 2.勾选显示隐藏的文件夹&#xff1a; 3.点击确定即可。

MES系统如何帮助企业提高生产效率

万界星空科技推出的制造执行MES系统&#xff0c;通过一系列先进的技术手段和管理理念&#xff0c;显著提高了制造业工厂的生产效率。以下是MES系统帮助提高生产效率的详细分析&#xff1a; 一、实时监控与快速响应 实时监控生产状态&#xff1a;MES系统能够实时采集生产线上的…

java 代码块

Java中的代码块主要有三种类型&#xff1a;普通代码块、静态代码块、构造代码块。它们的用途和执行时机各不相同。 普通代码块&#xff1a;在方法内部定义&#xff0c;使用一对大括号{}包围的代码片段。它的作用域限定在大括号内&#xff0c;每当程序执行到该代码块时就会执行其…

SpringMVC的基本使用

SpringMVC简介 SpringMVC是Spring提供的一套建立在Servlet基础上&#xff0c;基于MVC模式的web解决方案 SpringMVC核心组件 DispatcherServlet&#xff1a;前置控制器&#xff0c;来自客户端的所有请求都经由DispatcherServlet进行处理和分发Handler&#xff1a;处理器&…

linux中如何启动python虚拟环境

找到python虚拟环境所在目录 执行下面的命令即可 source auth_python/bin/activate

linux 下neo4j的安装

一、neo4j简介 Neo4j 是一个高性能的 NoSQL 图形数据库,它将结构化数据存储在网络(从数学角度叫做图)上而不是表中。Neo4j 也可以被看作是一个高性能的图引擎,该引擎具有成熟数据库的所有特性。 neo4j与jdk版本对应 neo4j的版本需要与jdk版本相适配,否则容易出现安装失…

数据库原理之数据库基本概念

目录 前言 基本概念 数据库完整性 前言 今天我们来看看数据库的基本概念&#xff0c;帮助大家对数据库有一点点最基本的了解 基本概念 4个基本概念 数据data&#xff1a;描述事物的符号&#xff0c;数据库中存储的基本对象。 数据库Database&#xff1a;长期存储在计算机…

CentOS 7 搭建rsyslog日志服务器

CentOS 7 搭建rsyslog日志服务器 前言一、IP地址及主机名称规划1.修改主机名 二、配置rsyslog日志服务器1.安装rsyslog服务2.编辑/etc/rsyslog.conf 文件3.启动并启用rsyslog服务4.验证端口是否侦听 三、在rsyslog日志服务器上配置firewalld防火墙四、配置rsyslog日志客户端1.编…

25考研:今年初试时间比去年更早了?

过去5年考研初试时间安排如下&#xff1a; 24考研&#xff1a;2023年12月23-24日&#xff08;倒数第二个周末&#xff09; 23考研&#xff1a;2022年12月24-25日&#xff08;倒数第二个周末&#xff09; 22考研&#xff1a;2021年12月25-26日&#xff08;最后一个周末&#xf…