How to change FalloutDeath.js to javascript #pragma strict

I keep getting this error and I know is because of #pragma strict.
Can anybody help with fixing the script. Thank you!
Chepe

Assets/_Scripts/Player/FalloutDeath.js(7,56): BCE0019: ‘FalloutDeath’ is not a member of ‘UnityEngine.Component’.

function OnTriggerEnter (other : Collider)
{
// Player fall out!
if (other.GetComponent (ThirdPersonStatus))
{
other.GetComponent (ThirdPersonStatus).FalloutDeath(); //error line
}
// Kill all rigidibodies flying through this area
// (Props that fell off)
else if (other.attachedRigidbody)
Destroy(other.attachedRigidbody.gameObject);
// Also kill all character controller passing through
// (enemies)
else if (other.GetType() == typeof(CharacterController))
Destroy(other.gameObject);
}

// Auto setup the pickup
function Reset ()
{
if (collider == null)
gameObject.AddComponent(BoxCollider);
collider.isTrigger = true;
}

@script AddComponentMenu(“Third Person Props/Fallout Death”)

(other.GetComponent (ThirdPersonStatus) as ThirdPersonStatus).FalloutDeath();

–Eric

Thank you Eric! That did the trick! I’m learning new things everyday!

If I get another #pragma strict error for the Iphone, from the other things, that I want to accomplish from the Unity Samples, l will post it here …

Thank you again :slight_smile:

Chepe

Hi Eric:

I can see my spaceship crashing in the floor and then respawning again and again. But is not running on the Iphone and it has giving me the following error;

Assets/_Scripts/Player/FalloutDeath.js(7,79): BCE0019: ‘FalloutDeath’ is not a member of ‘ThirdPersonStatus’.

function OnTriggerEnter (other : Collider)
{
// Player fall out!
if (other.GetComponent (ThirdPersonStatus))
{
(other.GetComponent (ThirdPersonStatus) as ThirdPersonStatus).FalloutDeath();
//other.GetComponent (ThirdPersonStatus).FalloutDeath();
}
// Kill all rigidibodies flying through this area
// (Props that fell off)
else if (other.attachedRigidbody)
Destroy(other.attachedRigidbody.gameObject);
// Also kill all character controller passing through
// (enemies)
else if (other.GetType() == typeof(CharacterController))
Destroy(other.gameObject);
}

// Auto setup the pickup
function Reset ()
{
if (collider == null)
gameObject.AddComponent(BoxCollider);
collider.isTrigger = true;
}

@script AddComponentMenu(“Third Person Props/Fallout Death”)

Chepe

You’re sure FalloutDeath is a member of ThirdPersonStatus script? Another method is:

var script : ThirdPersonStatus = other.GetComponent (ThirdPersonStatus);
script.FalloutDeath();

–Eric

Not sure, but this is my ThirdPersonStatus, which I attached to my spaceship.

// ThirdPersonStatus: Handles the player’s state machine.

// Keeps track of inventory, health, lives, etc.

var health : int = 6;
var maxHealth : int = 6;
var lives = 4;

// sound effects.
//var struckSound: AudioClip;
//var deathSound: AudioClip;

private var levelStateMachine : LevelStatus; // link to script that handles the level-complete sequence.

private var remainingItems : int; // total number to pick up on this level. Grabbed from LevelStatus.

respawnPosition = Respawn.currentRespawn.transform.position;
Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up;
transform.position = respawnPosition + Vector3.up;

If that’s the entire script, there is no FalloutDeath() function it in, hence the error message. BTW, code is easier to read if you use code tags.

–Eric

Eric:

Thank you for the help. Once, I get it to run on the Iphone, I will post the code snippet here.

Later,

Chepe

Eric:

I added the function and it works like a charm …

Thank you, this is exciting!

ThirdPersonStatus.js

// ThirdPersonStatus: Handles the player's state machine.

// Keeps track of inventory, health, lives, etc.


var health : int = 6;
var maxHealth : int = 6;
var lives = 4;

// sound effects.
//var struckSound: AudioClip;
//var deathSound: AudioClip;

private var levelStateMachine : LevelStatus;		// link to script that handles the level-complete sequence.

private var remainingItems : int;	// total number to pick up on this level. Grabbed from LevelStatus.

function FalloutDeath (){


	respawnPosition = Respawn.currentRespawn.transform.position;
	Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up;		
		transform.position = respawnPosition + Vector3.up;


}