当前位置: 首页 > java >正文

RPG2.设置角色摄像机

为了能在debug中方便输出一些打印信息,创建一个空白的c++类文件,我是用的是RIDER,直接在public内进行类创建即可。

1.创建debugHelper

2.在debughelper内创建一个命名空间namespace

namespace Debug
{static void Print(const FString& Msg, const FColor& Color = FColor::MakeRandomColor(), int32 InKey = -1){if (GEngine){GEngine->AddOnScreenDebugMessage(InKey, 5.f, Color, Msg);UE_LOG(LogTemp, Warning, TEXT("%s"), *Msg);}}
}

3.在玩家类里重写beginplay,在beginplay内进行debughelper的函数使用

4.运行游戏,打开日志

出现logtemp,说明debughelper使用成功。可以使用debughelper用以测试。

5.创建角色摄像机

摄像机

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))UCameraComponent* FollowCamera;

弹簧臂

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))USpringArmComponent* CameraBoom;

接着在玩家角色内创建构造函数,在构造函数内实现创建组件


#include "Character/XMBCharacter.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/CharacterMovementComponent.h"#include "XMBDebugHelper.h"AXMBCharacter::AXMBCharacter()
{GetCapsuleComponent()->InitCapsuleSize(42.f, 96.f);bUseControllerRotationPitch = false;bUseControllerRotationYaw = false;bUseControllerRotationRoll = false;CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));CameraBoom->SetupAttachment(GetRootComponent());CameraBoom->TargetArmLength = 300.0f;CameraBoom->SocketOffset = FVector(0.0f, 55.0f, 60.0f);CameraBoom->bUsePawnControlRotation = true;FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);FollowCamera->bUsePawnControlRotation = false;GetCharacterMovement()->bOrientRotationToMovement = true;GetCharacterMovement()->RotationRate = FRotator(0.0f, 550.0f, 0.0f);GetCharacterMovement()->MaxWalkSpeed = 400.f;GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;}

6.打开项目,见此则成功

7.设置骨骼

http://www.xdnf.cn/news/2983.html

相关文章:

  • js day9
  • 按键精灵安卓ios辅助工具脚本:实用的文件插件(lua开源)
  • 解决ktransformers v0.3 docker镜像中 operator torchvision::nms does not exist 问题
  • Redis入门到实战——基础篇
  • JavaSE第12篇:接口interface
  • Shopify网上商店GraphQL Admin接口查询实战
  • keep-alive具体使用方法
  • 我心中的现代前端大厦
  • LabVIEW模板之温度监测应用
  • dx11 龙宝书 第五 六章 流水线
  • leetcode 2962. 统计最大元素出现至少 K 次的子数组 中等
  • 规范编码策略以及AST的应用的学习
  • 如何使用 Nacos 对 Python 服务进行服务发现与注册
  • 【Dify系列教程重置精品版】第三章:Dify平台的本地化部署
  • Idea 如何配合 grep console过滤并分析文件
  • 关于浏览器对于HTML实体编码,urlencode,Unicode解析
  • Janus-1B评测
  • vue 优化策略,大白话版本
  • 一页概览:统一数据保护方案
  • Discord多账号注册登录:如何同时管理多个账户?
  • 全球667629个流域90m分辨率数据(流域参数含:面积、长度、宽度、纵横比、坡度和高程等)
  • 借助Spring AI实现智能体代理模式:从理论到实践
  • 案例解析:基于量子计算的分子对接-QDOCK(Quantum Docking)
  • 2025年深圳软件开发公司推荐
  • Laravel+API 接口
  • Mybatis-plus代码生成器的创建使用与详细解释
  • 环境-疲劳载荷综合试验系统
  • AI日报 - 2025年04月30日
  • Weiss Robotics的WPG与WSG系列紧凑型机器人夹爪,精准、灵活、高效
  • LoRA 微调技术详解:参数高效的大模型轻量化适配方案