Announcement

Collapse
No announcement yet.

[Question/Request] Left Click to Move/Attack

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Question/Request] Left Click to Move/Attack

    I'm looking to create a Diablo 2 style combat system.
    To be clear, even though I say Diablo 2 I don't mean tie an ability called 'Attack' to left click.

    Picture the "Top Down Template". When you load that up, it already has the left click to move part. I want to add the ability to also attack an enemy if the point that I clicked has an enemy there.
    I really wish I had a video showcasing this. I'm not sure if my description makes sense. I simply want left click to move your character to the point and check if an enemy is there. If an enemy is there, it should use an attack animation, swing at the enemy and deal damage accordingly.

    Are there any resources that can help with learning this? Free or otherwise? Or do any of you out there know how to do this? I'd really appreciate the help.

    #2
    I think you should look at learning AI. Knowing how to setup BehaviorTrees, BlackBoards, and making your own decorators, tasks, and services will get you on the right path. What your asking can be done a several different ways, most of them are 'hacky", but creating your own AI system I think would be your best, and most correct way, to achieve this.

    Comment


      #3
      There are already mouse functions built into unreal such as onmouse over events which you can use .
      https://docs.unrealengine.com/latest...ouseInterface/

      Always best to research or at least attempt things yourself before just asking for the answers otherwise you will never develop your skills . Alternatively create your own simply line trace down from mouse pos and see if it hits an enemy if it does move to location and call attack function etc. Another alternative is to add a collision box to the player and when you move to pos check of any enemies enter collision box . There are many ways to do things experiment and find out what works for you
      Last edited by EniGmaa; 07-20-2016, 03:07 AM.

      Comment


        #4
        I wasn't looking for someone to do the work for me. I just wanted to be pointed in the right direction. Thanks for the info.

        Comment


          #5
          There's a few ways you can do this.

          The fastest/easiest (but not necessarily best.) way is to cast your trace hit (which tells the character where to move) to an enemy. If it fails, do what it does now.

          It if succeeds, get distance between player and hit target. If >200 tell player to move to hit actor. Else play attack animation and do attack sequence that does damage or whatever.

          Comment


            #6
            Originally posted by TheQuiet1994 View Post
            I wasn't looking for someone to do the work for me. I just wanted to be pointed in the right direction. Thanks for the info.
            Sorry didn't mean to sound so harsh and didn't realise you were so new to the forums . All I meant is that if you had google searches for answers to you're question first you would have found there are tons of already answered questions on both this forums he answerhub the wiki etc which you could have used meaning no need to post . Anyway regardless like suggested here there are multiple ways to do what you need to do . So try every method you can find and like I said see what works for you . This will help you to get better and understand things better .

            As the character is going to be semi autonomous (attack automatically , move on click rather than input ) I think personally like the other user suggested you should use ai and blackboards but for the simplest way to do it you can use simple move to node to move character and then check distance between player and enemy unit of its within range then commence attacking .

            Whenever I'm trying to do something new for the first time I break it down into steps . So first how do I make character move ?? Google all possible answered experiment one best way to make character move. Next how do I make character stop at right location within range of enemy ?? Google all answers try everything find what works best . Next how do I make character attack automatically ?? Google answer try all different methods find what works best ? Next how do I add damage when player attacks ?? Google etc etc break everything down into tiny jigsaw pieces and then slowly bit by bit put it all back together that is essentially how to program

            Just experiment it will make you better in the long run. welcome to the forums :-p
            Last edited by EniGmaa; 07-21-2016, 03:05 AM.

            Comment

            Working...
            X