Unity is great I had an issue with it's state management system, which is seemingly going to get worked out. I might just switch back to complete my project.
Anyone wanna give a script example of a function from Unity that feels comfortable for a C-Script/Lite-C user?
For instance, how would I write things like camera looks at me, enemy follows me, state switches from attack to flee...
Camera looks at me (all in C#):
public Transform playerPtr;
void Update()
{
transform.LookAt(playerPtr);
}
assign it to the camera in the editor, and drag n drop the player into the "playerPtr" field. done.
Enemy follows player is simliar:
public Transform playerPtr;
void Update()
{
transform.LookAt(playerPtr);
transfor.Translate(Vector3.forward * 20); // Move enemy into his forward Vector
}
Apply to enemy, drag n drop player into the playerPtr field, done.
For statement switches, i actually always use ENUMS
private enum MoveStates
{
ATTACK,
FLEE,
IDLE
}
private MoveStates moveState;
...
// If player comes too close, flee
if(Vector3.Distance(transform.position, playerPtr.position) < 1))
moveState = MoveStates.FLEE;
...
void Update()
{
switch(moveState)
{
case MoveStates.FLEE:
transform.LookAt(playerPtr);
transform.Translate(-Vector3.forward * 10);
break;
}
}
It would run away backwards, looking at the player, but just to get an idea how you would make it.
Is it that what you wanted to know?
EDIT:
i left out the class definitions and library includings, as this is genereated automatically when creating a script anyway and looks the same for almost any script anyway.
it is just a plain:
using UnityEngine;
using System.Collections;
public class scriptName : MonoBehaviour
{
void Start()
{
}
void Update()
{
}
}