- Home /
Question by
keyshawnwebb15 · Aug 28, 2021 at 08:35 PM ·
c#physicscharactercontrollerattacking
Lunging with Character Controller
Hiya, I'm having a bit of trouble coming up with a way to have my player properly lunge at an enemy without gutting my code. I am using Physics as well as a Character Controller
but Im just drawing a blank
the most relevant code I have for this is:
void Update ()
{
enemies = Physics.OverlapSphere( this.transform.position , 10f );
foreach( var enemy in enemies )
{
if( Input.GetMouseButtonDown(0) && !isWeapon )
{
transform.LookAt( enemyPos );
StartCoroutine( DashAttack() );
//rb.AddForce( enemyPos.position * hyperSpeed * Time.deltaTime );
}
}
}
IEnumerator DashAttack()
{
transform.Transform(Vector3.forward *hyperSpeed * Time.deltaTime);
yield return new WaitForSeconds(5);
}
void OnDrawGizmos ()
{
Gizmos.DrawWireSphere( this.transform.position , 10f );
}
I've taken a decent sized break from Unity so I apologize if my code is looking a little spaghetti-o, I tried to cut out most of the unimportant stuff.
EDIT: also open to ideas I have tried options before the coroutine but barely a sign
Comment
Your answer
Follow this Question
Related Questions
How do I solve this error? 2 Answers
I want my Player to have collision physics 1 Answer
Distribute terrain in zones 3 Answers
Locking a CharacterController Object to the Y axis 1 Answer
Player Control. Roller Ball with Cube Acceleration. 1 Answer