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.

Newcomers DBPro Corner / First Time Posting - Big(ish) Problem

Author
Message
KasseyusAncient
21
Years of Service
User Offline
Joined: 14th Mar 2003
Location: United Kingdom
Posted: 15th Mar 2003 07:03
Hey All.

This is my first time posting, or using DBPro in a manner which could amount to somthing interesting.

I primarily work with 3D Graphics, so being able to use program I figured would be an asset.... I used to program basic in AMOS back in the days, not anything spectacular, but ya know.. Dabbled.. ANYWAY...

Have a problem and I thought ya'll might be able to lend a hand.. Its alittle problem on a thing I`m writing... Its 5am and I just cannot seem to wrap my head around it, goes like this...

I have a BattleBot, and he can stand anywhere in my arena... but, I want him to face his enemy should the situation call for it, I had him spinning in circles, but that did'nt help much, I first reasoned I could use Pythagaruses Theorum.. er.. or however you spell it, but that could only give me the distance between them, its just the angle that eludes me.. The answer is in there somewhere, but I just cannot think of it...

If anyone has any idea's, I would appreciate it..

Thanks
Know Thy Enemy...
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 15th Mar 2003 07:12
u could use a simple method that snaps him to look or you may want to use a slower rotation for realism.


obj1num is the object u want to point

obj2num is the object u want to point to

point object objnum1 object position x(obj2num),object position y(obj2num),object position z(obj2num)

KasseyusAncient
21
Years of Service
User Offline
Joined: 14th Mar 2003
Location: United Kingdom
Posted: 15th Mar 2003 17:03
Thanks, I did not know about that command. Sounds like just what I need...

However, after abit of experienting and testing, I just cannot seem to get it to function, no matter what variables or numbers I use to specify XYZ, The thing just wont budge.. Any Idea's?

and now it seems to be crashing for no reason ...

Ahh.. Programming...Fond Memmories.

Know Thy Enemy...
Elric
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 15th Mar 2003 22:14
Don't know if this is any use, but I'm working on something similar - I've used :

yrotate object intRobot, atanfull(x#-x2#, z#-z2#)

where :
x#, z# are coords of Robot u want to point to
x2#, z2# are coords of your Robot
intRobot is object number of the robot you want to rotate

"The question isn't who is going to let me; it's who is going to stop me." - Ayn Rand
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 16th Mar 2003 06:01
What about Set Object Orientation? That may work. Im sure there is an AI tutorial out there that will help you out. Some come with DB.

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
KasseyusAncient
21
Years of Service
User Offline
Joined: 14th Mar 2003
Location: United Kingdom
Posted: 18th Mar 2003 03:38
yrotate object intRobot, atanfull(x#-x2#, z#-z2#)

where :
x#, z# are coords of Robot u want to point to
x2#, z2# are coords of your Robot
intRobot is object number of the robot you want to rotate

Yeah.. I knew it had somthing to do with Tan or Cos or some similar Mathamatical Thingy, I just could not work it out, I think I missed that day at school .

I tried that code snippet, It did not work at first, but after a while I tried reversing the variables and my robot follows the target with total accuracy now Thanks for the help Below is the final gobbldigook of a peice of code that works

Direction = ATanFull(BBX-TBX,BBZ-TBZ)
`
Set Cursor 100,100
Print "Direction:- ";Direction;"."
Print TBX-BBX
Print TBZ-BBZ
`If Direction=<0 Then Direction=Direction-(Direction*2)
`Print "Reversed Direction:- ";Direction
YRotate Object 2,Direction
`
If Inkey$()="w" Then TBZ=TBZ+5
If Inkey$()="x" Then TBZ=TBZ-5
If Inkey$()="a" Then TBX=TBX+5
If Inkey$()="d" Then TBX=TBX-5


I guess its time to move onto phase 2... guess its time to think what phase 2 is going to be .

Know Thy Enemy...

Login to post a reply

Server time is: 2024-11-13 00:02:12
Your offset time is: 2024-11-13 00:02:12