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.

Author
Message
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 5th May 2005 11:30
i have an enemy AI system that works well, but has a few problems. like when his misile gets within a certain range it will home, but then if it gets behind me it will turn aroudn and come back. i dont want it to do taht last part. is there some way that once it's past me it cant home anymore?

enemy AI:


enemy shootmisile subroutine:
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 5th May 2005 21:51 Edited at: 5th May 2005 21:52
give the rocket its own xyz coordinate (newxvalue etc.) then if the target's z is lower than zero, die or somthn
that's what I'dd do

please reply
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th May 2005 23:40
What do you think of this code:



The "id" will turn towards "target" at a given speed ("turningspeed#").
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 8th May 2005 11:59 Edited at: 8th May 2005 12:00
that works fine on a 2d plane, but my game is full 3d. i have been tweaking that for several days to conform to my game and still cannot get it to work. what am i doing wrong???



oh yeah, and dont worry about why i switched the if endif statement around for x rotation. that was just something i tried and didnt work. its still exactly the same thing, just flipped around for no reason and i was too lazy to re-flip.

Who can withstand the awesome power of the almighty Lord of the Butmunch?
waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 8th May 2005 17:41
I recommend dropping the angle X refrence, just for simplicity.


first save old data
angy#=object angle y(id)
angx#=object angle x(id)

Then, simply cheat and use the function
point object ID,targetx#,targety#,targetz#

followed by
tanglex#=object angle x(id)
tangley#=object angle y(id)
tanglez#=object angle z(id)

Then, use the code above for turning speed
and then

rotate object ID,tanglex#,newangley#,tanglez#

this should work ...

but, if you want fancier code,
you could simply do a test on how much, and in which direction,
the anlges change and limit them to some number ...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th May 2005 21:04
Sorry guys, i found a bug in my function.
This is the updated 1:

ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 9th May 2005 11:13 Edited at: 9th May 2005 11:14
here's my problem. i want it to track on 2 dimensions, up and sideways (xrotation and yrotation). when the enemy shoots at me, it will turn too high up or too far down and miss me, even if i go slowly and straight at him. i already gave you my code. please tell me how to do what i want to do and what i did wrong.

Who can withstand the awesome power of the almighty Lord of the Butmunch?
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 9th May 2005 19:06
The angle values don't match. If you use x angles you have to rewrite your code instead of copy it.

Suggestion: draw it on a piece of paper! It works with me...
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 10th May 2005 07:41
ok. but ive tried every concievable conbination of x, z, and y values for the atanfull part. none of them work.

Who can withstand the awesome power of the almighty Lord of the Butmunch?
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th May 2005 03:18
I did it!!! A full 3D lock on function!

Here it is:



I found it when i was printing the x-angle and the y-angle on the screen.
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 17th May 2005 03:20
HALELUJAH!!!!!!!!!!!!!!!!!!!!!!!!!!! ur a genious! dude, you rock!!! thank you sooooooo much. this has been the major stopping block in the creation of my game, and now it's gone! now lets see how long it takes before another one gets in my way,... anyways, thank you so much !!!!

Who can withstand the awesome power of the almighty Lord of the Butmunch?
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th May 2005 03:38
Man, i have some bad news for you: It doesn't work.

When you pitch and turn, you are rotating around your z-axis. Wich means it won't work...
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 17th May 2005 05:07 Edited at: 17th May 2005 05:37
well, i guess i found the new stumbling block. that works great in that one bit of code in itself, but when i use it in my program it turns way the heck the wrong way. i haven't a clue why it doesnt work. this is my only hint: in the bit of code you gave me, i added the move object command. but when i do, although it will point at the target, it will not move in the direction of the target.

Who can withstand the awesome power of the almighty Lord of the Butmunch?
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 17th May 2005 05:38 Edited at: 17th May 2005 05:39
it worked fine in your code, though. hmmmmmm, i wonder,... could you not just add the same algorithm for the angle but for the z axis? I'll try that.

Who can withstand the awesome power of the almighty Lord of the Butmunch?
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 17th May 2005 05:45
alas! it wont work. oh well. i was thinking of changing the game to a helicopter game, and helicopters can't lock on to stuff with their misiles. but still, if someone can find a way, PLEASE TELL ME!!!

Who can withstand the awesome power of the almighty Lord of the Butmunch?
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th May 2005 20:39
Maybe you can make a dummy object wich points at the target.



I didn't test it, but it might even work!!!

Don't give up your fps!
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th May 2005 20:45
Oh, before i forget. you can also ajust it a little by using:



instead of:

ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 24th May 2005 06:57
I will try that.

Your Head A-Splode

Login to post a reply

Server time is: 2025-05-23 02:14:56
Your offset time is: 2025-05-23 02:14:56