OK, so I’m trying to make a very basic platforming game to get myself accustomed to Unity. Right now, I’m trying to understand how the C# scripting actually works.
Right now, I’m trying to make my character land on a platform. And I don’t have much but the default script right now:
using UnityEngine;
using System.Collections;
public class Shantae : MonoBehaviour {
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
}
If it follows with just about everything else I’ve understood about platformers, I just have to detect the collision and move my character (Shantae) to the top pixel of the platform minus 1. To do that, I just get the position of the platform and reset Shantae’s y position.
From what I understand about Unity scripting so far, I would be doing this change in the Update() function.
I can pretty much look at documentation for how to do all of that, but I still wonder:
- Is it possible to change object positions in a script like this? or is that something I have to do in the editor?
- I’m familiar with object-oriented programming, but I’m not sure how exactly I would get the position of a platform or any object. Surely every object has that bit of info, but how do I use it?
I’m still just trying to understand how everything works together. By the way, both objects have a Box2D collider associated with them.
Thanks for any help, guys.