简体   繁体   English

尝试为我的自上而下的统一 3D/2.5D 游戏制作 Dash

[英]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.我正在开发类似于archvale的游戏并进入地牢,我正在尝试创建一个破折号功能。 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.该游戏与 ETG 类似,它是一款使用自上而下格式的 2D 精灵的 3D 游戏。

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;
        }
    }

}

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.你可以做一个 transform.translate 或者你可以根据玩家正在看的地方或鼠标位置进行传送。 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/您可以查看本教程,它可能会对您有所帮助: https ://generalistprogrammer.com/unity/unity-2d-dash-movement-effect-learn-to-how-to-tutorial/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM