- Home /
Objects move on own
i was wondering if there was any scripts out there for an object to move on its own. i've looked everywhere and i mean everywhere. I am making an indie horror so help would be much apprecitated and thanks for the help.
What do you mean "$$anonymous$$ove on its own"? You need to be a little more specific. For instance, is it just going from A to B? Is it interacting with environment? Is it moving randomly?, Can the player interact with it or even kill it? Should it perform a specific action depending on particular situation? All in all, be a little more specific.
"move on its own" is why we have object-oriented program$$anonymous$$g (OOP). Each object should only care about itself and perhaps do some handling on objects related to it (children, parents). This way you can write code for that object so that object will work 'on its own', regardless of how other objects behave.
If you haven't learned about OOP, you'll absolutely want to take some beginner lessons in that (there are plenty of tutorials if you google 'c# oop beginner tutorial'). It's tricky to learn, but it's extremely rewarding once you've got it figured out. Best of luck. :)
Answer by Negagames · Apr 13, 2013 at 08:01 PM
I'm not sure exactly what you're looking for, but this might help. If you are looking to have just have an object simply move through a scene, use you can use rigidbody physics to do that. See: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.html http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html
Answer by Ethan1moody · Apr 18, 2013 at 08:02 PM
I mean by moving on its own by like trigger to set the objectoff to mov on its own and to move a set distance of my choice.
Answer by watercat · Apr 16, 2018 at 07:19 PM
if I understood the qustions changes on OnTriggerEnter OnTriggerStey this is c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TeleportExit : MonoBehaviour {
public Transform targets;
public Transform ball;
private void OnTriggerExit(Collider theObject)
{
{
ball.position = targets.position;
}
}
}
this is js if you want to move protect the side
#pragma strict
private var gos : GameObject[];
private var g : GameObject;
public var apostasi : int;
function Start () {
gos= GameObject.FindGameObjectsWithTag("p1");
g=gos[0];
}
function Update () {
}
function OnTriggerStay (other : Collider){
if(other.gameObject.tag == "Teleport 1"){
g.transform.position.y+=apostasi;
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Audio Destroy Help! 1 Answer
How can I make a object non enterable? 2 Answers
Finding desabled gameobjects using know positions 0 Answers
I'm making a horror game and I need help with item pickup 1 Answer