ue4 曲线图实现 蓝图_UE4[蓝图]只需一秒!最速实现【二段跳】

409c3188129290a78e4d00e244ec7340.png

我是刘茗,一个专注各种有趣玩法的开发者。

本次带来的是二段跳的教程。

在许多动作游戏中,都有着【二段跳】这样的游戏系统。本文将教大家一个最快实现二段跳的方法。

在Character头文件中,我们可以找到:

最大跳跃次数的定义

    /**
     * The max number of jumps the character can perform.
     * Note that if JumpMaxHoldTime is non zero and StopJumping is not called, the player
     * may be able to perform and unlimited number of jumps. Therefore it is usually
     * best to call StopJumping() when jump input has ceased (such as a button up event).
     */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category=Character)
    int32 JumpMaxCount;

在Character.cpp中,这个参数会在CanJumpInternal_Implementation函数中被使用。

5cd43691ba4a538c7deb9346d86235a8.png

因此,继承Character类的对象可以修改上述参数来实现

303c76de68fb295ab3cca7daee3afd6f.png

当我们把这个参数改成2的时候……二段跳已完成

通过修改这个参数,我们还可以实现三段跳、四段跳、各种跳都可以!

看到这里,觉得不够过瘾的朋友们在这里附上……彩蛋

跳跃系统的分析与研究

首先看一下Jump函数:

94087e35b4c90d195037ad87c9b627c5.png

这里发现bPressedJump被设置成了true,那么这个变量在哪里被使用了呢?在CheckJumpInput函数中。

180bd126e5071a479df492336e35c937.png
const bool bDidJump = CanJump() && CharacterMovement->DoJump(bClientUpdating);

在上面这一行代码中,我们发现这里调用了CharacterMovement组件的DoJump函数。

跳转到DoJump函数中

1f74e7e0810a9caedfa94a7a5d7125bd.png

这里对Velocity的Z值进行了赋值,以及设置了运动模式为Falling。

显然——

这个便是Jump功能真正实现函数了。

此外,Character类还提供了一些蓝图接口供开发者定制。

	/** Let blueprint know that we were launched */
	UFUNCTION(BlueprintImplementableEvent)
	void OnLaunched(FVector LaunchVelocity, bool bXYOverride, bool bZOverride);

	/** Event fired when the character has just started jumping */
	UFUNCTION(BlueprintNativeEvent, Category=Character)
	void OnJumped();

在跳跃和落地时,可以添加一些定制化的功能。

最后祝热爱自己事业的朋友们——

人(帅/美)( )大

bd380ac6a8571e4f19f153b004b8238b.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值