小编Ter*_*l56的帖子

我的"if"语句没有按预期工作

在我Unity C#的Android游戏中,我想检测到最接近角色的游戏对象是我正在寻找的那个(左),并且,如果游戏的玩家没有在屏幕上向左滑动(swipeLeft),我想要改变我的代码中的一个值叫做strike.但它运作不正常.

当我在游戏视图中时,leftSwipe值每次都不起作用(当if函数被移除时它会发生)并且罢工根本不会改变.我想知道如何解决这个问题,或者是否存在替代此问题的方法.

这是if声明:

if ((closestPlatform = left) && (leftSwipe = false)) { strike = 1; }
Run Code Online (Sandbox Code Playgroud)

这是整个C#脚本:

using UnityEngine;
using System.Collections;

public class SwipeChecker : MonoBehaviour
{

    public float maxTime;
    public float minSwipeDistance;

    float startTime;
    float endTime;

    Vector3 startPos;
    Vector3 endPos;

    float swipeDistance;
    float swipeTime;
    public float swipeScore;

    public GameObject left;
    public GameObject right;
    public GameObject up;
    public GameObject down;
    public GameObject swipeChecker;
    public GameObject[] platforms = new GameObject[5]; …
Run Code Online (Sandbox Code Playgroud)

c# if-statement unity-game-engine swipe

1
推荐指数
1
解决办法
280
查看次数

标签 统计

c# ×1

if-statement ×1

swipe ×1

unity-game-engine ×1