Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I've done it. Here's the code for my game now!

using UnityEngine;class M:MonoBehaviour{}using UnityEngine;class H:M{public bool h;public Rigidbody R;public Transform T;public Animator A;void OnTriggerEnter(Collider c){if(c.tag!="p")return;if(h){R.velocity=Vector3.zero;R.position=T.position;}else{A.SetTrigger("r");}}}using UnityEngine;class G:M{float i(string a)=>Input.GetAxis(a);public Rigidbody R;public float S;public Transform C;void FixedUpdate(){R.AddForce(new Vector3(i("h"),0.0f,i("v"))*S);C.position=transform.position;}}

And here's each individual script broken out:

// MonoBehaviour wrapper (to avoid repeating such a long inheritence)

using UnityEngine;

class M:MonoBehaviour

{

}

// Hole/Story Object (This is a two-object script. One handles entering a trigger and teleporting the player which is the hole, the other shows an animation whenever a trigger is entered.)

using UnityEngine;

class H : M{

public bool h;

public Rigidbody R;

public Transform T;

public Animator A;


void OnTriggerEnter(Collider c) {

if (c.tag != "p") return;

if (h) {

R.velocity = Vector3.zero;

R.position=T.position;

}

else

{

A.SetTrigger("r");

}

}

}

// And this is the player controller, which captures input using a small macro optimization

using UnityEngine;

class G : M {

public Rigidbody R;

public float S;

public Transform C;

void FixedUpdate() {

R.AddForce(new Vector3(Input.GetAxis("h"),0.0f,Input.GetAxis("v"))*S);

C.position=transform.position;

}

}

... I just did the math. I was wrong. I did my input wrong, complicated it, and added characters. The NEW character count is now 473, down from 488. Still, super excited to finally have mechanics! Now to build a game :P

In the end, I gutted the whole "golf controller" style for directly controlling the golf ball rolling (which is oddly similar to Unity's primary tutorial, Roll-a-Ball), which yielded a lot more fun ideas and results.