Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411581 Posts in 69386 Topics- by 58445 Members - Latest Member: Mansreign

May 05, 2024, 08:17:03 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)AI and arrows
Pages: [1]
Print
Author Topic: AI and arrows  (Read 1231 times)
MaTX
Level 0
**



View Profile WWW
« on: July 10, 2010, 08:16:48 AM »

Hi again Smiley (Sorry for my bad english)
I have got two questions for you!
1)How to make an arrow? I'm trying to do a clone of Ninja Rampage and i want to make the archer :D
Imho the creators made an "arrow" movieclip with the arrow in which frames have animations and motion of the arrow. They didn't describe the parabolic motion of the arrow by code, but graphically. Is this the easiest solution? Consider that also in my game enemies will launch arrows only horizontally.

2)Write an AI for the game. Well.. i don't know anything about ai :D
But it shouldn't be so difficult.
Normally the enemy is in "idle state", he turns himself sometimes. When he see the player, he goes in state "allert". If the enemy is close, he goes in state "Attack" else if the player hasn't escaped vertically, he goes in the state "follow". In case the player has escaped vertically, he returns in "allert" state. Correct?
The problem is:
-How to know when an enemy see the player?

2b)I want the player attacks enemy without pressing a key. If he gets close to an enemy
, he suddendly attacks. But with this method enemy won't ever kill the player :D
What do you suggest me? Should i give enemies a bigger range of attack?
Thanks, MaTX.
Logged
nikki
Level 10
*****


View Profile
« Reply #1 on: July 10, 2010, 10:17:45 AM »

Quote
-How to know when an enemy see the player?
you could try to plot a line between the enemy and the player, if that line didn't hit any 'view obstructing' objects the enemy can see you

Quote
1)How to make an arrow? I'm trying to do a clone of Ninja Rampage and i want to make the archer :D
Imho the creators made an "arrow" movieclip with the arrow in which frames have animations and motion of the arrow. They didn't describe the parabolic motion of the arrow by code, but graphically. Is this the easiest solution? Consider that also in my game enemies will launch arrows only horizontally.
I wouldn't do it that way (movieclips many frames , no math) instead i would describe the parabolic motion of the arrow by code.
reminds me of that banana monkey game that came with Qbasic back in the day !

Quote
2b)I want the player attacks enemy without pressing a key
like the enemies, the player should only attack by itself when it sees the enemy (thus the enemy could see the player (when facing)) then its a battle between two opponent that are aware of each other and you could unleash many strategies, hacks or whatever to balance the fight a bit.
a quick fix could be for the enemy to face the player when he's near.

that'd mess up the rest off the game probably, but auto-attacking in a ninja game also does abit Wink
« Last Edit: July 10, 2010, 10:33:40 AM by nikki » Logged
MaTX
Level 0
**



View Profile WWW
« Reply #2 on: July 10, 2010, 12:22:14 PM »

you could try to plot a line between the enemy and the player, if that line didn't hit any 'view obstructing' objects the enemy can see you
Well, this is a solution. I'll try.

I wouldn't do it that way (movieclips many frames , no math) instead i would describe the parabolic motion of the arrow by code.
reminds me of that banana monkey game that came with Qbasic back in the day !
I'll try :| I will have to implement rotation ._.


like the enemies, the player should only attack by itself when it sees the enemy (thus the enemy could see the player (when facing)) then its a battle between two opponent that are aware of each other and you could unleash many strategies, hacks or whatever to balance the fight a bit.
a quick fix could be for the enemy to face the player when he's near.

that'd mess up the rest off the game probably, but auto-attacking in a ninja game also does abit Wink
My game isn't a ninja game anymore. It's just a copy :D
It's a stealth game, if the enemy see you, you're dead so there are no problems in making enemies attacking better :D
Logged
Theotherguy
Level 1
*



View Profile
« Reply #3 on: July 10, 2010, 12:39:14 PM »

Quote
I wouldn't do it that way (movieclips many frames , no math) instead i would describe the parabolic motion of the arrow by code.

No, bad. Simulate the arrow as a point mass affected by gravity. Use simple ballistics calculations to figure out what angle and velocity to shoot the arrow at.

In other words, you don't need to be doing any modeling for ballistic projectiles, or any other kind of object in the game. Use simulation instead.

For rotation of the arrow, just turn it towards its velocity vector at any time.

Logged

muku
Level 10
*****


View Profile
« Reply #4 on: July 12, 2010, 12:08:36 AM »

Quote
I wouldn't do it that way (movieclips many frames , no math) instead i would describe the parabolic motion of the arrow by code.

No, bad. Simulate the arrow as a point mass affected by gravity. Use simple ballistics calculations to figure out what angle and velocity to shoot the arrow at.

I don't see why using a parabola directly would be inherently "bad"? If you know gravity will be the only force acting on the arrow, this option is easier and cheaper to implement and you stay out of troubles with unstable behavior under varying framerates.
« Last Edit: July 12, 2010, 03:19:21 AM by muku » Logged
nikki
Level 10
*****


View Profile
« Reply #5 on: July 12, 2010, 01:29:10 AM »

Quote
No, bad.
i didnt get that either:

when you let your arrow be a point-mass thats affected by gravity/speed/acceleration you'd probably end up with a parabole...

Logged
deemen
Level 0
***


View Profile WWW
« Reply #6 on: July 13, 2010, 07:41:54 PM »

Quote
I wouldn't do it that way (movieclips many frames , no math) instead i would describe the parabolic motion of the arrow by code.

No, bad. Simulate the arrow as a point mass affected by gravity. Use simple ballistics calculations to figure out what angle and velocity to shoot the arrow at.

In other words, you don't need to be doing any modeling for ballistic projectiles, or any other kind of object in the game. Use simulation instead.

For rotation of the arrow, just turn it towards its velocity vector at any time.



Simulation is ridiculously inefficient unless you are dealing with extra forces (drag, turbulence, planetary gravity). If it's only gravity, there is no point simulating.
Logged

Project Lead - Programmer @ Crankshaft Games
Current Project: Party of Sin
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic