RE: Help me with my new website!
January 25, 2018 at 10:43 pm
(This post was last modified: January 25, 2018 at 10:50 pm by bennyboy.)
As for not learning C#-- trust me, that's a mistake. It's close enough to Java and a couple other languages that I just consider them all different flavors rather than complete new word views to get used to. Most of the scripting is just using variable to store properties, and to say what happens when events are triggered. Basically, I have a few things like the following:
You can see that this is the event handler for the player entering the "win" box in the marble game. There's no kind of complex programming at all-- just a collection of "if" blocks that set various properties when something happens: if it is the player who entered the box, and if all the Ethans have been destroyed, set the "Win" condition to true, etc.
That's pretty much all game scripting is: saying WHEN you want to trigger and event, and saying WHAT you want to happen when that event is triggered. You need to know about 1% of C# to be able to do that effectively. Things like animations are done in the designer with pre-built assets (like you "add collider" to an object, and it all gets done automatically for you).
I'd estimate the whole marble game is maybe 100 lines of code right now, which 15 years ago, might have got you to successfully display a blank DirectX window but not much more than that.
Code:
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "WinZone")
{
if (!DoingLerp){
if (EthanCountingSystem.CanWin == true){
WinText.gameObject.SetActive(true);
if (DoingLerp == false){
DoingLerp = true;
Pos1 = rb.transform.position;
Pos2 = GameObject.FindGameObjectWithTag("WinZone").transform.position;
TimeStartedLerping = Time.time;
rb.constraints = RigidbodyConstraints.FreezePosition;
HaveWon = true;
}
}
}
}
}
That's pretty much all game scripting is: saying WHEN you want to trigger and event, and saying WHAT you want to happen when that event is triggered. You need to know about 1% of C# to be able to do that effectively. Things like animations are done in the designer with pre-built assets (like you "add collider" to an object, and it all gets done automatically for you).
I'd estimate the whole marble game is maybe 100 lines of code right now, which 15 years ago, might have got you to successfully display a blank DirectX window but not much more than that.