弹丸类以及魂类的构想

UE4里有弹丸的MovementComponent,十分明显需要这个。

 

但是魂类呢?放在Tick里,我已经实现了,但是总感觉是对资源的浪费

于是

从Learning.C++.by.Creating.Games.with.UE4.2015上复制下来的简单怪物AI代码,

void AMonster::Tick(float DeltaSeconds)
{
Super::Tick( DeltaSeconds );
// basic intel: move the monster towards the player
AAvatar *avatar = Cast<AAvatar>(
UGameplayStatics::GetPlayerPawn(GetWorld(), 0) );
if( !avatar ) return;
FVector toPlayer = avatar->GetActorLocation() - GetActorLocation();
toPlayer.Normalize(); // reduce to unit vector
// Actually move the monster towards the player a bit
AddMovementInput(toPlayer, Speed*DeltaSeconds);
// At least face the target
// Gets you the rotator to turn something
// that looks in the `toPlayer` direction
FRotator toPlayerRotation = toPlayer.Rotation();
toPlayerRotation.Pitch = 0; // 0 off the pitch
RootComponent->SetWorldRotation( toPlayerRotation );
}

看了一下,感觉魂类用ProjectileMovement会比较好,如果需要让物体不停旋转用RotatingMovement

可以少些很多东西

2016.4.6

发现CrowdFollowingComponent,以后可以试着用一下

转载于:https://www.cnblogs.com/blueroses/p/5306513.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值