Blaze
Blaze

Reputation: 1

Trying to make a Dash for my top down unity 3D/2.5D Game

Im working on a game similar to archvale and enter the dungeon and I'm trying to create a dash function. Ive tried using force and some other methods I've searched for online but I haven't been able to find anything. Any ideas?

This game is a similar perspective to ETG being a 3D game using 2D sprites in a top down format.

Thanks!

EDIT: This is code I tried using but it didn't work at all. It is code I found online.

    using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Dash : MonoBehaviour
{
    public class PlayerMovement : MonoBehaviour
    {
        public float dash = 3000f;
        public bool DashTime = true;

        // Use this for initialization
        void Start()
        {
            bool DashTime = true;
        }

        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown("f"))
            {
                GetComponent<Rigidbody>().AddForce(new Vector2(dash, 0), ForceMode.Force);
                StartCoroutine(LateCall());
            }
        }
        IEnumerator LateCall()
        {
            yield return new WaitForSeconds(0.05f);
            GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezePositionX;

            yield return new WaitForSeconds(0.06f);
            GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None;
        }
    }

}

Upvotes: 0

Views: 1172

Answers (1)

Lukas Thompson
Lukas Thompson

Reputation: 1

Without any code or anything to look at its kind of hard to answer the question. You could do a transform.translate or you could teleport based on where the player is looking or the mouse location. There are a ton of ways you could create a dash effect but without anything to go on it's really up in the air as to what solution you come up with.

You can check out this tutorial and it might help you: https://generalistprogrammer.com/unity/unity-2d-dash-movement-effect-learn-to-how-to-tutorial/

Upvotes: 0

Related Questions