Challenge Create a Launch Pad
在头文件中定义网格体组件和重叠组件
UPROPERTY(VisibleAnywhere,Category="Components")
UStaticMeshComponent* MeshComp; UPROPERTY(VisibleAnywhere, Category = "Components")
UBoxComponent* OverlapComp;
导入头文件
#include "Components/BoxComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Components/ArrowComponent.h"
#include "GameFramework/Character.h"
#include "Kismet/GameplayStatics.h"
创建OverlapLaunchPad函数,重叠时发生弹射角色
UFUNCTION()
void OverlapLaunchPad(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
定义弹射力度和弹射角度
UPROPERTY(EditInstanceOnly, Category = "LaunchPad")
float LaunchStrength; UPROPERTY(EditInstanceOnly, Category = "LaunchPad")
float LaunchPitchAngle;
定义一个粒子系统
UPROPERTY(EditDefaultsOnly, Category = "LaunchPad")
UParticleSystem* ActivateLaunchPadEffect;
设置重叠组件及其尺寸,设置网格体组件作为基底
OverlapComp = CreateDefaultSubobject<UBoxComponent>(TEXT("OverlapComp"));
OverlapComp->SetBoxExtent(FVector(, , ));
RootComponent = OverlapComp; MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
MeshComp->SetupAttachment(RootComponent);
将OverlapLaunchPad函数和OverlapComp绑定在一起
OverlapComp->OnComponentBeginOverlap.AddDynamic(this, &AFPSLaunchPad::OverlapLaunchPad);
初始化弹射力度和弹射角度
LaunchStrength = ;
LaunchPitchAngle = 35.0f;
实现OverlapLaunchPad函数
void AFPSLaunchPad::OverlapLaunchPad(UPrimitiveComponent * OverlappedComponent, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
FRotator LaunchDirection = GetActorRotation();//获取Actor旋转度
LaunchDirection.Pitch += LaunchPitchAngle;//俯仰角,可以让Actor不直接按旋转量旋转,而是朝着某一角度进行旋转
FVector LaunchVelocity = LaunchDirection.Vector() * LaunchStrength;//弹射速率,将旋转量变为矢量再乘以弹射力度 ACharacter* OtherCharacter = Cast<ACharacter>(OtherActor);//强制转换为Character
if (OtherCharacter)
{
OtherCharacter->LaunchCharacter(LaunchVelocity, true, true);//调用游戏内置的发射函数,后面两个参数可用于重写当前速率,无论从哪个方向走入发射平台都能确保弹射速率的一致性 UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ActivateLaunchPadEffect, GetActorLocation());//原地创建发射器
}
else if (OtherComp && OtherComp->IsSimulatingPhysics())//检测角色是否转换失败
{
OtherComp->AddImpulse(LaunchVelocity, NAME_None, true);//施加相同速率的推力 UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ActivateLaunchPadEffect, GetActorLocation());
}
}
Challenge Create a Launch Pad的更多相关文章
- Create Fiori List App Report with ABAP CDS view – PART 2
In the Part 1 blog, we have discussed below topics CDS annotations for Fiori List Report. How to cre ...
- ios Programming:The Big Nerd Ranch Guid(6th Edition) (Joe Conway & AARON HILLEGASS 著)
Introduction (已看) Prerequisites What Has Changed in the Sixth Edition? Our Teaching Philosophy How t ...
- Using Let’s Encrypt for free SSL Certs with Netscaler
Using Let’s Encrypt for free SSL Certs with Netscaler If you haven’t heard, Let’s Encrypt (https://l ...
- 2015年最佳的12个 CSS 开发工具推荐
CSS所能做的就是改变网页的布局.排版和调整字间距等,但编写 CSS 并不是一项容易的任务,当你接触新的 CSS3 属性及其各自的浏览器前缀的时候,你会发现很伤脑经.值得庆幸的是一些优秀的开发人员提供 ...
- Serial Port Programming using Win32 API(转载)
In this tutorial we will learn How to communicate with an external device like a microcontroller boa ...
- Gazebo機器人仿真學習探索筆記(七)连接ROS
中文稍后补充,先上官方原版教程.ROS Kinetic 搭配 Gazebo 7 附件----官方教程 Tutorial: ROS integration overview As of Gazebo 1 ...
- ROS_Kinetic_x 目前已更新的常用機器人資料 rosbridge agvs pioneer_teleop nao TurtleBot
Running Rosbridge Description: This tutorial shows you how to launch a rosbridge server and talk to ...
- Making my own Autonomous Robot in ROS / Gazebo, Day 2: Enable the robot
Day 2: Enable the robot Git Setting git checkout master git branch day2_enable_robot git push --set- ...
- 2.4G无线射频通信模块nRF24L01+开发笔记(基于MSP430RF6989与STM32f0308)(1.(2)有错误,详见更正)
根据网上的nRF24L01+例程和TI提供的MSP430RF6989的硬件SPI总线例程编写程序,对硬件MSP-EXP430RF6989 Launch Pad+nRF24L01P射频模块(淘宝购买)进 ...
随机推荐
- C# 数据库批量插入数据之 —— SqlBulkCopy、表值参数
创建了一个用来测试的Student表: CREATE TABLE [dbo].[Student]( [ID] [int] PRIMARY KEY NOT NULL, ) NULL, ) NULL, [ ...
- Linux下weblogic10.3.6(jar)版本安装详解
一.安装前的准备 安装weblogic是需要JDK环境的,虽然weblogic有自带的JDK,但是我一般是自己选择JDK进行安装,如果你要自行安装,可以参考我的另一篇博客 https://www.cn ...
- CSS3 利用border-radius实现椭圆角
效果如图: border-radius共有8个属性值,有四个角,每个角对应两个值(分别是x轴和y轴的值). border-radius: 0 20% 20% 0/0 50% 50% 0; /的左右两边 ...
- Linux记录-安装LAMP和R环境
2.2 Apache httpd2.2.1 执行命令进行安装:yum install -y httpd2.2.2 开启服务:service httpd start2.2.3 设置开机自启动:chkco ...
- C#设计模式(9)——代理模式
1.代理模式介绍 在软件开发中有时会遇到不能直接使用对象的问题,如我们要使用的对象在进程外,甚至在远程的机器上,但是我们要使用这个对象的功能怎么办呢?代理模式就可以用来解决这个问题.举一个生活中的例子 ...
- sql递归查询 根据Id查所有子结点
Declare @Id Int Set @Id = 0; ---在此修改父节点 With RootNodeCTE(D_ID,D_FatherID,D_Name,lv) As ( Select D_ID ...
- http请求参数中文乱码的问题
如题,A项目带参数发送请求到B项目.刚开始还好,但是发觉 参数带中文 就出现问题了,变成了?? 解决方法:发送中文参数前先做处理 request.getSession().removeAttribut ...
- putty-psftp
putty-psftp putty文上传下载 open hostname cd directory lcd directory put file get file Example: open 192. ...
- js方法参数中含有单引号双引号的处理
最近在做项目时,遇到一个问题.当在js脚本中,拼接生成一个tr,然后添加到一个表格里. //假定testval是从后台传过来的数据 var testval = "含有'半角单引号的字符串&q ...
- HDU - 1540 Tunnel Warfare(线段树区间合并)
https://cn.vjudge.net/problem/HDU-1540 题意 D代表破坏村庄,R代表修复最后被破坏的那个村庄,Q代表询问包括x在内的最大连续区间是多少. 分析 线段树的区间内,我 ...