Grounded

my player is grounded when jumping on platfroms ,meanning that it has to land on top of a platform for that platform to be hit. i would like to make one of my platforms (only one of them ) to be able to get hit from the bottom by the player and have the player jumping up (Players head has to hit the bottom of the platform).

private var hit : RaycastHit;

// theTransformHit stores a reference to the last transform that the player jumped on so that we can
// destroy it if all the conditions are met to start a jump
private var theTransformHit : Transform;



// we need to make sure we're grounded before starting a new jump
public var grounded : boolean;


function FixedUpdate () {
	
	
		
			
		
 
	
	// always assume we're NOT grounded every step (and expect to be proved wrong by raycasting etc.)
	grounded=false;

	// check to see if we're on top of a platform - here we cast two rays, one on each side of the player
	// LEFT:
	if (Physics.Raycast (transform.position- Vector3.up * 0.5 + Vector3.right * 0.5, -Vector3.up, hit, 1, 1<<9)) {
		// we found ground, so set our grounded flag to true, so that the player will jump
		grounded=true;
		if(rigidbody.velocity.y<0){
			theTransformHit=hit.transform;
		}

	}
	// RIGHT:
	if (Physics.Raycast (transform.position- Vector3.up * 0.5 - Vector3.right * 0.5, -Vector3.up, hit, 1, 1<<9)) {
		// we found ground, so set our grounded flag to true, so that the player will jump
		grounded=true;
		if(rigidbody.velocity.y<0){
			theTransformHit=hit.transform;
		}
	}
		
	// do jumping, if we're on top of a platform
	if(jumpEnabled){
		if(grounded  rigidbody.velocity.y<0){
			doJump();
			// send a message to the platform to tell it to destroy itself
			theTransformHit.gameObject.SendMessage("hitPlatform");
		
			
		}
	}

Would you please stop spamming, this is your third thread on two different accounts. I believe I speak for the rest of us who use this forum that we don’t respond well to question spamming or inappropriate bumping, you’ll less likely receive a helpful response to your question.

i really need some help with it but no one is responding

Your response is childish. You spammed three threads in under 15mins. It may take hours, or a day, before a response is given. Bump a thread every once a day or so if needed.

@lion123 can you keep it to one thread, I have closed you other threads. Just bump this thread in the future.

fine i will just keep this one. sorry guys if i made anyone made and im sorry that my response is childish , i’ts just that i need this one code working and i can send my app to app store and im putting it up for free not like im hurrying to make money , sorry guys

There is a thread I responded to that has an example of how to make grounding work.

http://forum.unity3d.com/threads/101595-Move-script

Basically he is calling everything you can be “grounded” on “Ground” by tagging it. So if you register a hit on “Ground” you are grounded, when you leave the collision, you are not.

how would i be able to to tag this from my player to platform ?

	// always assume we're NOT grounded every step (and expect to be proved wrong by raycasting etc.)
	grounded=false;

	// check to see if we're on top of a platform - here we cast two rays, one on each side of the player
	// LEFT:
	if (Physics.Raycast (transform.position- Vector3.up * 0.5 + Vector3.right * 0.5, -Vector3.up, hit, 1, 1<<9)) {
		// we found ground, so set our grounded flag to true, so that the player will jump
		grounded=true;
		if(rigidbody.velocity.y<0){
			theTransformHit=hit.transform;
		}

	}
	// RIGHT:
	if (Physics.Raycast (transform.position- Vector3.up * 0.5 - Vector3.right * 0.5, -Vector3.up, hit, 1, 1<<9)) {
		// we found ground, so set our grounded flag to true, so that the player will jump
		grounded=true;
		if(rigidbody.velocity.y<0){
			theTransformHit=hit.transform;
		}
	}

i tried this : but did not work

function OnTriggerEnter (collision: Collision)
{
	if(collision.gameObject.tag == "Platform"  grounded == false  Platform)
	{
		grounded = false;
		
		
		if (Physics.Raycast (transform.position- Vector3.down * 0.5 + Vector3.left * 0.5, -Vector3.down, hit, 1, 1<<9)) {
		// we found ground, so set our grounded flag to true, so that the player will jump
		grounded=true;
		if(rigidbody.velocity.y<0){
			theTransformHit=hit.transform;
		}

	}
	// RIGHT:
	if (Physics.Raycast (transform.position- Vector3.down * 0.5 - Vector3.left * 0.5, -Vector3.down, hit, 1, 1<<9)) {
		// we found ground, so set our grounded flag to true, so that the player will jump
		grounded=true;
		if(rigidbody.velocity.y<0){
			theTransformHit=hit.transform;
		}
	}


		
	// do jumping, if we're on top of a platform
	if(jumpEnabled){
		if(grounded ){
			doJump();
			// send a message to the platform to tell it to destroy itself
			theTransformHit.gameObject.SendMessage("hitPlatform");
		
			
		}
	}

and also in platform1.js
i put in this :

private var Player : GameObject;
private var Platform : GameObject;
// we keep a reference to the game controller so that we can send it the occasional message, like telling it
// to add score when a platform is destroyed and telling it to spawn an effect when the platform disappears
private var gameControl : GameController;

// the width of the play area (used to keep the platforms within the play area - if you make the game wider, change the game width in gameController.js, as that's where we get its value from)
private var gameWidth : float;

function Start () {
	
     Player = GameObject.FindWithTag("Player");
     
     Platform = GameObject.FindWithTag("Platform");