Hi im working in my own game alone with no help, i have been watching tons of tutorials and reading more, but english is not my mother lenguage so i cant seem to repoduce or to fully understand whats going on…
so for example if i want to create in unity a game object with is own gravity (Atract “projectile” but not the player)
var gameObject= gravity;
public var gameObjectGravity= 10
and if i want to “shoot” a game object that will be atracted to the gravity of that game object and when i press “E” botton the fuction of destroying will be set on or off. ( i took this code from another FPS as a basic to modify )
function start(){
if( Input.GetButtonDown( “e” ) )
var asExplosion : boolean = false;
var explosion : GameObject;
function (OnCollisionEnter collision : Collision );
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal );
var instantiatedExplosion : GameObject = Instantiate(
explosion, contact.point, rotation );
Destroy( gameObject );
}
thanks JamesLeeNZ your awesome for helping me out, now i cant try out the code because it says that this script is wrong or obsolete ??? something that haves going on with unity since update to 4.x…
using UnityEngine;
public class ActivateTrigger : MonoBehaviour {
public enum Mode {
Trigger = 0, // Just broadcast the action on to the target
Replace = 1, // replace target with source
Activate = 2, // Activate the target GameObject
Enable = 3, // Enable a component
Animate = 4, // Start animation on target
Deactivate= 5 // Decativate target GameObject
}
/// The action to accomplish
public Mode action = Mode.Activate;
/// The game object to affect. If none, the trigger work on this game object
public Object target;
public GameObject source;
public int triggerCount = 1;///
public bool repeatTrigger = false;
void DoActivateTrigger () {
triggerCount–;
if (triggerCount == 0 || repeatTrigger) {
Object currentTarget = target != null ? target : gameObject;
Behaviour targetBehaviour = currentTarget as Behaviour;
GameObject targetGameObject = currentTarget as GameObject;
if (targetBehaviour != null)
targetGameObject = targetBehaviour.gameObject;
switch (action) {
case Mode.Trigger:
targetGameObject.BroadcastMessage (“DoActivateTrigger”);
break;
case Mode.Replace:
if (source != null) {
Object.Instantiate (source, targetGameObject.transform.position, targetGameObject.transform.rotation);
DestroyObject (targetGameObject);
}
break;
case Mode.Activate:
GameObject = true;
break;
case Mode.Enable:
if (targetBehaviour != null)
targetBehaviour.enabled = true;
break;
case Mode.Animate:
GameObject.animation.Play ();
break;
case Mode.Deactivate:
GameObject.active = false;
break;
}
}
}
Just some general housekeeping to help us help you…
In future, could you please wrap your code in the Code, or PHP tags? Also, when you are stating there is an error, please copy and paste the full error and identify which line of code it is applicable to?
Function Start(){
}
Function Start(){
}
Judging by the sounds of your error, a function used by one or more of your lines of code is no longer supported or will be removed in an upcoming version of the Unity Editor.