How to make a Charged attack

Updated on January 18, 2017 in  [R] Tutorials
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
4 on January 17, 2017

I am wondering is there any tuts out there on how to code a charge attack and if not can I get some pointers in the API for it?

  • Liked by
  • HunGARE
Reply
3 on January 17, 2017

Could you have an int that counts up when you hold the mouse down. If you only click the mouse button the int doesn’t go up much, so it’s a regular attack. If you hold the button, the int goes up a lot, and triggers a power attack. There are probably better ways of doing it, but that’s how I would do it.

on January 17, 2017

So make a int var like 

float int x = 1f;
blahDblah += x;
then something.time = …

Devoted
on January 18, 2017

Yeah so have an int that increases with a mouse click, and when the mouse isn’t being clicked reset to the original value. Have if statements checking the value of the int, and if it reaches a certain high amount, initiate a power attack. Or else just do a normal attack.

on January 18, 2017

Need a little more help on what and where Do I need to place the delta.time and what else is needed in the code. 

using UnityEngine;
using System.Collections;
public class ChargeAttack : MonoBehaviour 
{
public void float Attack =.5f;
}
public void Update ()
{
if (Input.GetButtonDown("Fire1"): x>= y:Attack++)
{
Debug.Log(Input.mousePosition);
}
else ()
{
}
}

Show more replies
  • Liked by
Reply
Cancel