As for the collision i’m not quite sure. for starters you don’t need to put “UnityEngine” just put something like “function OnCollisionEnter (AnyName : Collision)”
then do the tag check like this:
if (AnyName.CompareTag (“floor”)) currentScore++;
(no need for the { } when there’s only one sentece in the loop)
If with this it doesn’t work, then you probably need to read more about collisions and triggers to see wich one actually works best for your case.
I’ve run into another block. This script for the parts of the building colliding into “floor” works great.
static var currentScore : int = 0;
function OnTriggerEnter(collisionInfo : Collider){
if (collisionInfo.CompareTag ("floor"))
currentScore++;
Destroy (GetComponent (CollisionWithFloorScoreUpdate));
}
But this one doesn’t?
static var currentScore : int = 0;
function OnTriggerEnter(collisionInfoGold : Collider){
if (collisionInfoGold.CompareTag ("floor"))
currentScore += 150;
Destroy (GetComponent (CollisionWithFloorScoreUpdate));
}
var valueOfObject = 2;
static var currentScore : int = 0;
function OnTriggerEnter(collisionInfo : Collider){
if (collisionInfo.CompareTag ("floor"))
currentScore += valueOfObject;
Destroy (GetComponent (CollisionWithFloorScoreUpdate));
}
I just passed in my own variable for the value of each box hitting the ground.
I played the demo. really fun. I just have one question. Are you removing the rigidbody component when they hit the ground and they are done moving? It was lagging way hard on my computer and I was wondering if it was due to the processes of keeping track of the physics applied to everything.