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

  • 相关阅读:
    Django第一天上课笔记
    easyui-datebox 只能获取当前日期以前的日期
    身份证号码 正则表达式 jquery
    动态修改属性设置 easyUI
    easyUi onLoadSuccess:、onChange这些事件不能嵌套使用!!!!
    jstl无法调用js
    decode
    easyui-panel 滚动条禁用
    js文件引用js文件
    硬编码
  • 原文地址:https://www.cnblogs.com/blueroses/p/5306513.html
Copyright © 2011-2022 走看看