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

UE学习记录part7

93、collision presets

展示简单碰撞

 如果没有简单碰撞,可以添加

在运行时输入命令show collision能够更好的检测碰撞体

query collision才能检测物体间的碰撞,如果是physics collision,无法实现物体间的碰撞

如果是query collision和physics collision同时勾选,则可以实现物体间的block效果和物体间的物理交互效果(例如人能够踢飞石子)

或者例如对相机阻塞,但是对pawn不阻塞,就能实现暗门效果



94、overlap events

一个蓝图类下,不同组件可以设置不同的overlap事件,可以用在捡拾物品



95&96&97、delegates

删除蓝图overlap事件

----Item.h------

class USphereComponent;


UFUNCTION()
void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

UFUNCTION()
void OnSphereEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

---------Item.cpp--------
#include "Components/SphereComponent.h"



void AItem::BeginPlay()
{
	Super::BeginPlay();
	Sphere->OnComponentBeginOverlap.AddDynamic(this, &AItem::OnSphereOverlap);
	Sphere->OnComponentEndOverlap.AddDynamic(this, &AItem::OnSphereEndOverlap);
}

void AItem::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	const FString OtherActorName = OtherActor->GetName();
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(1, 30.f, FColor::Red, OtherActorName);
	}
}

void AItem::OnSphereEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
	const FString OtherActorName = FString("Ending Overlap with: ") + OtherActor->GetName();
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(1, 30.f, FColor::Blue, OtherActorName);
	}
}

 

相关文章:

  • 免密登录远程服务器shell脚本
  • 【Linux】:守护进程化
  • 工具层handle_excel
  • Java-泛型总结
  • 蓝桥杯备考:奶牛晒衣服
  • Android NDK --- JNI从入门到基础的全面掌握 (上)
  • github上传本地文件到远程仓库(空仓库/已有文件的仓库)
  • python环境集成整理
  • Linux动态库和静态库
  • RAGFlow + LlamaIndex 本地知识库RAG增强架构与实现直播智能复盘
  • 【入门初级篇】布局类组件的使用(1)
  • 如何通过Python实现自动化任务:从入门到实践
  • 2025年 cocosCreator 1.8 定制 JavaScript 引擎
  • Web Component 教程(五):从 Lit-html 到 LitElement,简化组件开发
  • 用css绘制收银键盘
  • 实验三 内存管理
  • RocketMQ 架构
  • std::move
  • Unity3D开发AI桌面精灵/宠物系列 【二】 语音唤醒 ivw 的两种方式-Windows本地或第三方讯飞等
  • 一些常用的docker镜像及命令 python各版本(持续更新中)
  • 呼伦贝尔市委常委、组织部长闫轶圣调任内蒙古交通集团党委副书记
  • 北京朝阳涉住宅组团地块126亿元成交
  • 药明康德一季度净利增长89%,在手订单增超四成至523亿元
  • 上海灵活就业人员公积金新政有哪些“创新点”?
  • 外交部:欢迎外国朋友“五一”来中国
  • 一个失败的赛季咎由自取,皇马只能把希望留到夏天