Changeing the attack behaviour

I have Been trying to play around with attacking options but it looks like the Mouse clicks are tied to the Animations of attacking.

How would you change it to continuous attack with getMousbuttonDown and attack once per click with getmousebutton

Actually, I would say that the mouse clicks are NOT tied to the animations the way we have combat set up…

Our setup
By clicking on a target, the Fighter component takes over and implements auto attacks, pacing these attacks out based on the attack speed of our character or weapon. Continuing to click on the same target has no effect, as the target will already have been set, and the timer will still throttle attacks based on attack speed.

What you appear to be looking for
By clicking on the target, the character will launch an attack animation. By continuing to hold the mouse button, the character will exhibit the auto attack behavior mentioned in our setup.

Getting the precise behavior you’re looking for may require some restructuring of both PlayerController and Fighter, and you might find this breaks completely when we get to the IHandleRaycast section of the course, but here’s a quick and dirty. I can’t guarantee this will work for the totality of the course (I suspect it won’t).

At the end of the Fighter.Hit() method, add

target=null;

This will clear the target and give you single click action.

Make sure in InteractWithCombat that you use if(Input.GetMouseButton(0)) and not Input.GetMouseButtonDown(0) and this will continously keep the target active in Fighter even when Hit() clears the target.

Privacy & Terms