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 Professional Discussion / follow me commands ai

Author
Message
Jon wu
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 8th Nov 2013 17:10
can some one help me with this ai code so that the object can follow my player heres the code

make object cube 89898, 100 : Rem Cone
color object 89898,rgb(255,0,255)
position object 89898, 300,object size(89898)*.75,500
show object bounds 89898
make object collision box 89898, -30,-30,-30, 30,30,30, 1
set object collision on 89898 : Rem Check the Player Cube
if object collision(89898,1)=1 then delete object 1

Hasty
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 8th Nov 2013 19:29 Edited at: 8th Nov 2013 19:29
Is your "player" the camera or another object?

If it's the camera then use something like:
POINT OBJECT 89898,camera position x(),camera position y(),camera position z()
MOVE OBJECT 89898,1


D.D.
Jon wu
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 9th Nov 2013 00:32
The player is an object that the gamer moves around with and im tryin to make a randomly generated object follow it

Hasty
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 9th Nov 2013 12:16
@Jon we
Take a look to this piece of code.




Cheers.

I'm not a grumpy grandpa
Jon wu
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 12th Nov 2013 17:37
heres the code i put
follow the player
do
point object 89898,object position x(1),object position y(1),object position z(1)
move object 89898,0.01
scroll object texture 89898,0,0.002
if object collision(player,enemy)>0 then gosub endsection
sync
loop
but it says it cannot understand the command

Hasty
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Nov 2013 18:52
At the top of that example, I defined floor_ as object 100 , player as object 1, and enemy as object 2...let say:
if object collision(player,enemy) is exactly the same as if I put:
if object collision(1,2) then.....

in your case would be:
if object collision(89898,1)....if this is your object to collide with, and of course , you will have to create first the label endsection

The label is a part of the code where you continue the program...something like a function and then comes back to the same point

Take a look to this example:



I'm not a grumpy grandpa
Jon wu
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 13th Nov 2013 17:09
i managed to fix the command problem but whenever i put it into a do loop the whole game crashes but the cube still moves heres waht i put

point object 89898,object position x(1),object position y(1),object position z(1)
move object 89898,10
scroll object texture 1,0,0.002


ps. i already got the collision box working in another part of my code.

Hasty
Jon wu
12
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 14th Nov 2013 05:14
Actually I got it to work cause I put it near the end of my game but the problem is that I can't move

Hasty
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 14th Nov 2013 15:26 Edited at: 14th Nov 2013 15:27
Quote: "i managed to fix the command problem but whenever i put it into a do loop the whole game crashes but the cube still moves heres waht i put

point object 89898,object position x(1),object position y(1),object position z(1)
move object 89898,10
scroll object texture 1,0,0.002"


Everything that you 'let happen' in your game, must be inside your loop, or called from within your loop (through function, subroutine, coroutine, etc.)...

Quote: "point object 89898,object position x(1),object position y(1),object position z(1)
move object 89898,10
scroll object texture 1,0,0.002"


This must be in your loop, or called from you loop. Why the scroll command? Has nothing to do with moving the actual object.

Regards Sph!nx
www.mental-image.net

Login to post a reply

Server time is: 2026-07-07 11:20:13
Your offset time is: 2026-07-07 11:20:13