zoukankan      html  css  js  c++  java
  • 弹丸类以及魂类的构想

    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,以后可以试着用一下

  • 相关阅读:
    第三章:数据结构决定程序
    第二章:Rotate、变位词
    iOS常用宏定义
    去除重复的数据
    iOS开发者一些建设性的建议
    [iOS]应用内支付(内购)的个人开发过程及坑!
    UIDynamic(物理仿真)
    扇形进度
    iOS 之加密方式
    UIPresentationController
  • 原文地址:https://www.cnblogs.com/blueroses/p/5306513.html
Copyright © 2011-2022 走看看