Have a little problem that need to to be solved.
To get a better understanding for the Game here´s a quick link with the early build (playale in browser)
When the PUC hits the wall or an obstacle i want to prevent it from moving further on. Because at the moment if you hit a wall/obstacle you still can move on for 2sec untill the scene resets.
PUC (charakter) control Script:
using UnityEngine;
using System.Collections;
public class puc_controller : MonoBehaviour
{
public float moveSpeed = 25.0f;
public AudioClip menuEnterLevel;
Animator anim;
void Start () {
anim = GetComponent<Animator> ();
}
private void Update()
{
if (Input.GetMouseButton(0))
{
Vector3 targetPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
targetPos.z = transform.position.z;
transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
}
}
void OnTriggerEnter2D(Collider2D coll)
{
if(coll.gameObject.tag == "Respawn")
{
audio.PlayOneShot(menuEnterLevel);
anim.SetBool("die", true);
}
}
}
Reset Script: ```csharp
**using UnityEngine;
using System.Collections;
Create a method in the controller to disable the script or use a bool to evaluate if the player can move. When you are responding have it toggle so the player can no longer move until it has respawned. You can use
Thanks for you answer, sounds logic to me, but as i said im quite new to Unity and Programming, i understand what you mean but dont know how to use i mean where and in which script to put this
I’m assuming after you restart, it reloads everything all over again. If the controller persists from scene to scene then we need to change the logic. But I don’t see it here so this should do it.