Skip to content

Commit

Permalink
somewhat hacky but it works on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
bozmir committed Dec 18, 2024
1 parent ce20e77 commit 1c606d5
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 38 deletions.
58 changes: 51 additions & 7 deletions Assets/Scenes/Main.unity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 42 additions & 14 deletions Assets/Scriptables/Projects/CurrentProject.asset

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Assets/Scripts/KerstSpecial/MobileButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Netherlands3D.Events;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Netherlands3D.Twin
{
public class MobileButton : MonoBehaviour, IPointerUpHandler, IPointerDownHandler
{
private RaceController controller;
private bool isPressed = false;
public float moveValue = 0;

private void Start()
{
controller = FindObjectOfType<RaceController>();
}

public void OnPointerDown(PointerEventData eventData)
{
isPressed = true;
}

public void OnPointerUp(PointerEventData eventData)
{
isPressed = false;
}

private void Update()
{
if (controller != null && isPressed)
{
controller.MoveHorizontally(moveValue);
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/KerstSpecial/MobileButton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 10 additions & 17 deletions Assets/Scripts/KerstSpecial/RaceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public class RaceController : MonoBehaviour
};

[SerializeField] private FloatEvent horizontalInput;
[SerializeField] private FloatEvent verticalInput;
[SerializeField] private FloatEvent upDownInput;
[SerializeField] private BoolEvent jumpInput;

[SerializeField] private TextAsset routeFile;
Expand All @@ -61,12 +59,13 @@ public class RaceController : MonoBehaviour

private void Start()
{
freeCam = FindObjectOfType<FreeCamera>();
freeCam = FindObjectOfType<FreeCamera>();

horizontalInput.AddListenerStarted(MoveHorizontally);
verticalInput.AddListenerStarted(MoveForwardBackwards);
upDownInput.AddListenerStarted(MoveUpDown);
jumpInput.AddListenerStarted(Jump);
if (!Application.isMobilePlatform)
{
horizontalInput.AddListenerStarted(MoveHorizontally);
jumpInput.AddListenerStarted(Jump);
}

GetCoordinatesForRoute();
GenerateZones();
Expand Down Expand Up @@ -179,6 +178,10 @@ private void FixedUpdate()

private void Update()
{




CheckNextCoordinate();
if (routeCoords == null)
return;
Expand Down Expand Up @@ -282,16 +285,6 @@ public void MoveHorizontally(float amount)
playerMoveVector += Vector3.forward * playerSpeed * Mathf.Clamp01(amount);
}

public void MoveForwardBackwards(float amount)
{
//playerMoveVector += Vector3.forward * playerSpeed * Mathf.Clamp01(amount);
}

public void MoveUpDown(float amount)
{

}

public void GetLayers()
{
CartesianTiles.TileHandler th = FindObjectOfType<CartesianTiles.TileHandler>();
Expand Down

0 comments on commit 1c606d5

Please sign in to comment.