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 / Point object problem(s)

Author
Message
Yodaman Jer
User Banned
Posted: 29th Sep 2008 17:14
Well, I am currently attempting to make a game and I'm getting done pretty well so far. The only thing that annoys me is that when I try to make an NPC (Non-Player Character) constantly point at the player, it rotates along EVERY axis. I just want it to rotate along the Y so that it turns and watches you as you go down the corridor...
here's my code (taken from the Binary Moon Tutorials):

`rotate box object
yrotate object 16,y

`point the enemy at the sphere
xPoint#=object position x(1)
yPoint#=object position y(1)
zPoint#=object position z(1)
point object 16,xPoint#,yPoint#,zPoint#



The problem is I think, that I am using Gravity. The demo from the tutorials doesn't. So, since my character can jump and such, it thusly follows along the X axis, making for one weird looking helper-guy (I know, lame name, but that's all I got right now. )

Does anybody have any ideas about how to overcome this (admittedly) small issue?

Yodaman Jer

That guy with no idea of what to say here. Except that he is a geek, and likes cheese. And pickles. But mostly cheese.
Yodaman Jer
User Banned
Posted: 30th Sep 2008 01:01 Edited at: 30th Sep 2008 01:01
I tried experimenting, but nothing works. Can someone please help me?

To elaborate on my experimenting...

I tried removing the x axis variable, and just like I suspected it did nothing. Ah well....

Yodaman Jer

That guy with no idea of what to say here. Except that he is a geek, and likes cheese. And pickles. But mostly cheese.
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 30th Sep 2008 02:54
try just rotating on the y axis only.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Sep 2008 09:38
a couple of things to try:

Don't point at the object's y position. Keep the object that is looking at the other objects own y (effectively only rotating on the y axis like BN2 suggests):



If you have limbs and the lookobject (helper guy) has a head, rotate that only on the x axis. You can calculate that using atanfull(y2-y1,sqrt((x2-x1)^2+(z2-z1)^2)) where y2 is the object to look at y and y1 is the looking object y and sqrt(etc) is the distance between the two objects. You may have to use y1-y2 to get the correct angle if it is reversed (down instead of up) . You can rotate the rest of the body as in the previous example.

Enjoy your day.
Yodaman Jer
User Banned
Posted: 30th Sep 2008 21:51
@Latch: Thanks dude! I'm not quite that good enough a programmer yet to understand your other method (the one that isn't in the code box), and I'm certainly not good enough with regular math to calculate square roots to anything, but I appreciate the effort you put into it to help me.



Yodaman Jer

That guy with no idea of what to say here. Except that he is a geek, and likes cheese. And pickles. But mostly cheese.

Login to post a reply

Server time is: 2026-07-06 03:58:43
Your offset time is: 2026-07-06 03:58:43