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 I make an object "see" another?

Author
Message
Video Boy
21
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 9th Jul 2005 20:58
This image will let you understand better what I have in mind.
http://devilmaster.supereva.it/viewfield.gif
The FOV is 90° in the example image, but it may vary.
I have two objects. One of them rotates on its Y axis. Other objects move around it. How do I tell if this object is "looking at" another object?
RiiDii
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 10th Jul 2005 04:09 Edited at: 10th Jul 2005 04:10
Go over to the 20 Line Coding Challenge and look for a thread called RiiDii's mostly useful functions. One of the snippets in there does exactly what you are trying to do.

Edit: Darn it. I thought I was in the newb forum. I don't know if that code will work directly in DBC, but the math should work. Post a comment in the mostly useful functions if you need help translating it.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Jul 2005 03:13
The Binary Moon tutorial has an AI, that turns the object to a specified point. You can use this to check if the person is "looking" to the object.

Immunity and Annihalation makes Immunihalation...
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 11th Jul 2005 04:53 Edited at: 11th Jul 2005 04:53
Sven B, I´ve studied the binary moon limmitrush code alot, but I can´t understand how to implement it´s AI code into a FOV code. What
part are you talking about?

please reply

Your signature has been erased by a mod because he was in the mood for it
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 12th Jul 2005 00:37
Well, the one that the enemies turn towards the target...

I made a quick snippet:



is the most important part.

Immunity and Annihalation makes Immunihalation...
Yusaku
22
Years of Service
User Offline
Joined: 21st Jan 2003
Location: NYC
Posted: 12th Jul 2005 04:33
I just point an object toward the player if he or she is close enough. I haven't checked the code below to see if it works yet, but I'm sure it will. I use a similar routine in my RPG.

I'm not very good at math, so I use a lot of regular commands to regulate my games. I hope this is easy to understand, as it is for me.
Video Boy
21
Years of Service
User Offline
Joined: 21st Mar 2004
Location:
Posted: 14th Jul 2005 07:44 Edited at: 14th Jul 2005 07:49
Thank you Sven B, it works.
Actually, I had to make a correction to your code to make it work, because your version of the "most important part" will only work if the object rotates counterclockwise. If it rotates clockwise, you'll remain "viewed" even when the object is showing its back side to you.
Here's how I modified it:

This way, VIEWED will also be set to zero if the first condition is false.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 14th Jul 2005 17:11
Indeed, my apologies for this...

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2025-05-22 22:37:15
Your offset time is: 2025-05-22 22:37:15