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 / Move object towards camera

Author
Message
zerosimms
15
Years of Service
User Offline
Joined: 25th Feb 2011
Location:
Posted: 30th Mar 2011 23:19
Hey all

I wonder if you can help, I downloaded an example the other day but for the life of me can't find the post. Anyway, I'm trying to get an object (zombie) to move slowly towards the camera.

I've set this up, first I've done 'Make camera 1'

then made the following variables:

cpz=camera position z(1)
cpx=camera position x(1)
zpx=object position x(6)
zpz=object position z(6)

Then said:

IF cpx<zpx+200 AND cpz<zpz+200 AND cpz>zpz-200 AND cpx>zpx-200
SET OBJECT SPEED 6,1
MOVE OBJECT 6,-1
endif

The object (6) moves but only on one axis, Z, I think. It starts to move when the camera (1) is in range (200) of the object but that's not what I want.

Any help?

www.bensimms.co.uk
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 31st Mar 2011 03:12 Edited at: 31st Mar 2011 03:13
first off all your cpx etc.. commands have to be real numbers so cpx
becomes cpx#


try this:




My software never has bugs, it just develops random features.
C4: silly putty for men.
zerosimms
15
Years of Service
User Offline
Joined: 25th Feb 2011
Location:
Posted: 31st Mar 2011 12:45
Thanks Commico, it's working after a bit of tweaking

www.bensimms.co.uk

Login to post a reply

Server time is: 2026-07-11 14:56:23
Your offset time is: 2026-07-11 14:56:23