MDK style falling game..

Hi guys, we’re coding a falling game in the style of MDK cut scene levels, effectively we are trying to pick things up when we float down. We’ve got this script -

function Update(){
	
	//	basic falling script, downwards
	transform.position.y-=0.5;
	//	axis controls	
	transform.Translate(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

}


function OnCollisionEnter (collision : Collision) { 

if (collision.collider.gameObject.tag == "collectZ"){ 
	
	//add 1 point to your score
	scoreScript1.score += 1; 

	//destroy Z collectables
	Destroy (collision.collider.gameObject);
	}
}

So we’re not sure whether to use OnControllerColliderHit - given that we dont have a controller collider, we switched to using OnCollisionEnter. So we have a capsule collider on our falling character, and several tagged objects called collectZ that are collectable in other levels using OnControllerColliderHit and the 3rd person controller, but dont work in this adapted context.

Any help much appreciated!

Cheers,

Will

31116--1135--$picture_3_211.png

You probably want to use a rigidbody with capsule collider instead.

Then you simply control forces or velocity to move the character. This way you will get OnCollisionEnter messages or if you dont want to stop on collectibles, make them trigger objects and override OnTriggerEnter.

No they are not trigger, we’ve tried giving them colliders of various types (box, sphere etc), do u recommend we make them triggers and use OnTriggerEnter?

will give that a go…

Thanks!

If you dont want the character to stop when hitting them they should be triggers.

But the important part is that you add a rigidbody to the character.

that works fine thanks!!