Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
LucasH42
11
Years of Service
User Offline
Joined: 7th Nov 2013
Location:
Posted: 13th Nov 2013 03:53
Hello! today i am looking for something specific. i am looking for a way to make an object follow you and where in my text i should put it. im going to try to post my lines of coding on here, but if i cant, plz answer. thx(:
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Nov 2013 09:36
One way, is just to point the object at the camera:

Point Object obj,camera position x(),camera position y(),camera position z()

Then move that object forward by the speed you want it to follow you:

Move Object obj,1.0


It's a cheap method, but it works - if you wanted something nicer, then you should look into doing a SQRT distance check, and with that you can have the object stay a fixed distance from the camera, even move back a little when the camera get's close - but that's a bit more advanced.

I am the one who knocks...
Jon wu
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 13th Nov 2013 17:04
@moderator i tried using that code but the only thing the object does is look towards the object that i want it to follow heres the code i put

Point Object 89898,camera position x(),camera position y(),camera position z()

Move Object 89898,5

Hasty
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Nov 2013 20:29 Edited at: 13th Nov 2013 20:31
1. Give your threads proper titles "help please!" doesn't help anyone, and it will make it hard for other people with the same problem to find answers you were given.
2. When you say "i am looking for a way to make an object follow you" do you want it to follow a camera or another object or what? "You" could be anything in a program.
3. "...and where in my text i should put it", this concerns me. If you know how your program works you should know where to put different procedures, even if you don't totally understand the code within them.
4. Why are you using object number 89898? That's just going to confuse people.
5. Do you have a loop? The object is probably moving 5 once and stopping, if you have a loop it should continue moving. If you aren't using a loop of some kind then you need to read up on the basic tutorials before getting into something like this. It's not hard but it wont make sense until you understand the basics of how programs work, you don't seem to have this yet as far as I can tell.
0. Welcome to the forum! Help yourself to a penguin:


Formerly OBese87.
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 13th Nov 2013 21:12
Wait, what? You just posted almost exactly the same thread last week and got several responses...
http://forum.thegamecreators.com/?m=forum_view&t=208671&b=1

http://www.indiedb.com/games/max-vs-mars
Jon wu
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 14th Nov 2013 05:17
I put 89898 cause if I put a small number there are many objects that already exists and I'm trying to make an object follow another object which the object being followed is the player and this is what we use at school not that I do this in my spare time

Hasty
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Nov 2013 16:34 Edited at: 14th Nov 2013 16:36
Quote: "I put 89898 cause if I put a small number there are many objects that already exists and I'm trying to make an object follow another object which the object being followed is the player"

What is object 89898? It would be a good idea to store the object number in a variable: creepObj = 89898 then it's clear what it is and you wont make the mistake of typing "898989" or something.

Another benefit of using variables for things like this is that if you decide to change the value you can change it throughout the program by just changing the assignment, eg creepObj = 2. Using a variable also means the object number could be changed mid-game, so you could do something like have only the closest object follow the player.
If you really don't want the follow object to change at all you could store the value in a constant, which can't be changed while the program is running.

If you wanted to give the object the next available number you could do something like this:

Have you used FOR loops yet? If you don't understand a command you can look it up in the help files.


Formerly OBese87.

Login to post a reply

Server time is: 2025-05-15 20:33:28
Your offset time is: 2025-05-15 20:33:28