Hi guys,
As you can tell from the title, I’m very much new to Unity and C#… I have coded (barely) in the past with HTML and C++…
Here is my issue: I created a first person movement controller thingy to move a cylinder around and jump on/off things. But I want to create a plane or terrain, below some floating blocks, that when you fall onto it or hit it, you are destroyed. Then from there have it destroy and then place you back on a floating block… that way when I fall I don’t fall for eternity and beyond.
What I have so far: I have some floating cubes to jump on and a flat terrain far below, I tagged the Terrain as “Enemy” so that it might work in this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FallLimit : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//if(Input.GetKeyDown(KeyCode.Space))
// {
// Destroy(gameObject);
// }
}
}
private void OnCollisionEnter(Collision collision)
{
if(collision.tag == "Enemy")
{
Destroy(gameObject);
}
}
Sadly an error comes back saying:
Assets/FallLimit.cs(23,14): error CS0116: A namespace cannot directly contain members such as fields or methods
How do I make this work??