给角色添加Power变化效果
添加速度值 根据power变化控制速度
BatteryCollectorCharacter.h
protected:
// APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
// End of APawn interface
UFUNCTION(BlueprintCallable, Category = "Pickups")
void CollectPickups();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power", meta = (BlueprintProtected = "true"))
float InitialPower;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float SpeedFactor;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power")
float BaseSpeed;
UFUNCTION(BlueprintImplementableEvent, Category = "Power")
void PowerChangeEffect(); // BlueprintImplementableEvent 表示该函数在蓝图中实现
BatteryCollectorCharacter。cpp
在UpdatePower中调整速度 并调用PowerChangeEffect
修改ThirdPersonCharacter 蓝图类 该类 继承自BatteryCollectorCharacter
修改构造函数 获得材质实例 并保存
在EventGraph中 实现PowerChangeEffect 函数, 根据当前Power/InitalPower 的值在两个颜色之间渐变 动态修改材质的BodyColor颜色(该参数可通过点击材质查看)
运行 人物颜色一点点发生变化