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.

DarkBASIC Discussion / How do you make a object follow you?

Author
Message
Jigga
20
Years of Service
User Offline
Joined: 13th Nov 2002
Location:
Posted: 24th Nov 2002 16:37
Yes, I recently have been experimenting with the
object on screen command. It works like this. The command will return 1 if the specified 3d object is on the screen.
My question is how do you make that object follow you if it appears on the screen.
SpiralMinice
20
Years of Service
User Offline
Joined: 14th Oct 2002
Location: United States
Posted: 24th Nov 2002 21:01
um ive never done this before so i dont know if it'll work but you might want to try something like this.

first i would try setting up a system that counts loops to help with timing like this:

REM here's the main loop
REM SRate is just what ever you have set your frame rate to.
do
if Loops < SRate
inc Loops
else
Loops = 0
endif
sync
loop

Now you can ask your program what loop you are on at any point in the program.

Now you can do something like this. (Guy is you and Folower
is the object following you)

REM this will ask for Guy's cordinance once every
REM second. FolowerNX# means Follower's new X cordinance.
if Loops = SRate
FollowerNX# = object position x(Guy)
FollowerNY# = object position y(Guy)
FollowerNZ# = object position z(Guy)
endif
point object Follower,FollowerNX#,FollowerNY#,FollowerNZ#
if object position x(Follower) = FollowerNX#
if object position y(Follower) = FollowerNY#
if object position z(Follower) = FollowerNZ#
else
move object Follower, FollowerSpeed#
endif
else
move object Follower, FollowerSpeed#
endif
else
move object Follower, FollowerSpeed#
endif

i hope that helps some though it might not work at all but fool around with it im pretty sure i got the right idea.

Come children and i shall bring you into unlevend
feilds of faraf fo sdlief dnevelnu otni uoy gnirb llahs i dna nerdlihc emoC
dark coder
20
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 24th Nov 2002 21:37
well you can make it much easier than that by using, note: 1 and 2 are the two objects used - 1 is you 2 is the follower.

point object 2,object position x(1),object position y(1),object position z(1)

move object 2,1 - thats how easy it is

l8er

----- dark coder -----
SpiralMinice
20
Years of Service
User Offline
Joined: 14th Oct 2002
Location: United States
Posted: 25th Nov 2002 00:31
oh yeah i guess that would work... geeze dark coder thanks for making me feal like such an ass. only joking.

Come children and i shall bring you into unlevend
feilds of faraf fo sdlief dnevelnu otni uoy gnirb llahs i dna nerdlihc emoC
Jigga
20
Years of Service
User Offline
Joined: 13th Nov 2002
Location:
Posted: 25th Nov 2002 23:28
Thanks for the code, but I have another question. How can
you limit how much the enemy can actually steer. Because with this code, the enemy object can steer 90+ degrees at any given point. How do you make it so that for example, the enemy object can steer a maximum of 30 degrees per second?

QuothTheRaven
20
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 30th Nov 2002 05:40
dark coder, lets say you were above the enemy. Point and move dont exactly apply there.
dark coder
20
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 30th Nov 2002 12:07
right thats a bit harder but here goes,
first you have to make a dummy object to find the ange the enemy has to turn,
eg:

load object "player.x",5
load object "enemy.x",1

make object plain 2,1,1 : hide object 2


controls for object 5(the player)

move object 1,1

position object 2,object position x(5),object position y(5),object position z(5)

point object 2,object position x(5),object position y(5),object position z(5)

anx#=object angle x(2)
any#=object angle y(2)
anz#=object angle z(2)

if anx#>ax# then inc ax# : if anx#<ax# then dec ax#
if any#>ay# then inc ay# : if any#<ay# then dec ay#
if anz#>az# then inc az# : if anz#<az# then dec az#

yrotate object 1,ax#
yrotate object 1,ay#
yrotate object 1,az#



that should work

l8er

----- dark coder -----
John H
Retired Moderator
20
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 30th Nov 2002 14:32
Well yaaaaaaa, what kinda game are you making? If you want a monster to hunt you check out

http://www.darkbasic.com/create.php?f=3d_tutorials_25.php

there. Cuz, you really cant have the monsters just, follow you. Well, I guess you COULD but I think it'd be better to have some AI.

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
Mnemonix
20
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 8th Dec 2002 03:11
I used the following technique on a monster in my game. He follows you and if he catches you you die. All is required is the position of the object being followed and the distance between the two objects (found out using sqrt). You just point the object at the other object and make it move. It will move towards the target even if he moves(Provided ur not a dumbass)

If you forget one little thing i shall have you shaved sterilised and destroyed: Jeffrey Goines
Naf
20
Years of Service
User Offline
Joined: 7th Nov 2002
Location:
Posted: 9th Dec 2002 13:22
i wonder if anyone could help me and my friend with a similar problem? we are trying to make a snake game like the one on Nokia phones but we arew using 3D objects for the animations. when we try to get the snake to turn (we are using turning circles instead of just turnin 90 degrees in one go). the snake starts vertical on the screen and we want it to turn to say horizontal but when we press the left or right key all that happens is that the entire snake moves to the right... the front object in the "caterpillar" like chain moves how we want but the other objects dont follow it properly. il post some code l8r if i can
Naf

if it works... DONT FIX IT!!!
just tweak it a bit around the edges till it dont work... THEN fix it!!!
-my BASIC programming motto

Login to post a reply

Server time is: 2023-09-30 20:37:33
Your offset time is: 2023-09-30 20:37:33