Dry goods sharing | UE game mouse double-click judgment

UE Unreal Engine is no stranger to game developers. 47% of console games on the market use Unreal Engine to develop games. As the core driving force of a game, its functions are very complete, including scene production, lighting rendering, action shots, particle effects, material blueprints, etc. This article introduces the double-click judgment of the game mouse in the process of Unreal Engine game development, let's take a look!

1. The UE has an interface for double-clicking the mouse on the UI. But if you double-click the item in the game, the monster may need to add its own judgment.

2. Judgment principle: two conditions are met

  1. Whether the position of two clicks of the mouse is within a certain range (eg: 20).
  2. Whether the time between two mouse clicks is less than a certain value (eg: 0.3 seconds).

3. Implementation of the blueprint

Condition 1:  Obtain the position of the mouse in the scene through the PlayerController; then subtract the position of the last mouse click to calculate whether the distance is less than 20.

Condition 2:  Obtain the computer system time through the Now method, and subtract the time of the last mouse click. Calculate whether the time difference is less than 0.3 seconds.

Regardless of whether it is a double-click or not, the position and time of the current mouse click are updated.

The content of this article "Dry Goods Sharing | UE Game Mouse Double-click Judgment" is organized and published by 3DCAT Metaverse real-time rendering cloud solution provider . If you need to reprint, please indicate the source and link: Dry Goods Sharing | UE Game Mouse Double-click Judgment

Guess you like

Origin blog.csdn.net/RealTime_3DCAT/article/details/128935818