I’m currently trying to make an IOS app with unity, as you can see in the picture I have a character, boxes and two buttons
I have made a script that lets my character move when the buttons are pressed,
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class Movement : MonoBehaviour
{
public Button storeButtonRight;
public Button storeButtonLeft;
public float speed = 100f;
public Transform player;
void OnEnable()
{
// storeButton.onClick.AddListener(MyFunction);//adds a listener for when you click the button
storeButtonRight.onClick.AddListener(() => moveCharacter(new Vector2(1, 0f)));
storeButtonLeft.onClick.AddListener(() => moveCharacter(new Vector2(-1, 0f)));
}
void moveCharacter(Vector2 direction)
{
player.Translate(direction * speed * Time.deltaTime);
}
}
This works and all, but my main problem is that my Collision won’t work, I added collision 2d objects to all the objects, but the player still walks right through them any help please?