Download

Handling mouse input based on player state

Hi guys,

I am trying to achieve a fundamental concept in my project (i cant call it a game yet). i have a top-down camera and click to move system. what i want to do next is highlight objects and enemies the mouse is hovering. but in the future i want to extend it so i want to make it flexible with blue prints.
im planning to include:

  • Highlight (change shader maybe? ) items (outline them) and enemies if the player is not in a select target or interact state.
  • Click to move, if the clicked target is an enemy or item, approach it until the attack or interact range is reached
  • if the player is going launch a projectile they should be able to select a target
  • if the clicked target is not reachable, calculate the next available navigation point.

right now i have achieved nothing as I am a total noob in unreal engine. any tutorials or examples would be appreciated.

Up. Anyone ?

Use the converMouseLocationToWorldSpace node, and use that to do a linetrace to figure out where the mouse is hovering. Use the break hitResult node to pull the hitActor, and based on that figure out what you want the player/game to do.

Bind this to an eventTick for things that happen on hover (displaying name/hp, or higligting for example)

Bind it to an inputEvent (e.g. leftMouseButton) for attacking, moving, spellcasting.

As for movement, look up tutorials on making AI movement and just adapt the code to your needs.