I’m quite new to C# and javascript
I’m trying to make the object not fall through the floor, but it shouldn’t be colliding with other objects then object “floor”.
Feel free to suggest guides (beginner) - Should I focus on C#, java or both?
Do it matter if I use some C# and some Javascript in my games or doesn’t it matter?
This code is just something I tried… I didn’t know it would be this hard moving from Game Maker to Unity.
using System.Collections;
public class gravity : MonoBehaviour {
void Start ()
{
}
void Update ()
{
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag=="Floor")
rigidbody.useGravity = false;
}
}
I suggest learning C#. It’s my favorite language. I like it better than UnityScript. Either way, I’d pick one language and stick with it.
I wouldn’t turn gravity off. The collider itself should be enough to stop the object from falling through the floor. If your object needs to collide with the floor but not other things, Unity has “Layer-Based Collision Detection” so you can control what collides with what.