Postdeleted.
Postdeleted.
*Post Delete by Me, Luaiscool*
Last edited by luaiscool on Tue May 13, 2014 2:11 am, edited 1 time in total.
http://xkcd.com/979/
Code: Select all
if signature = true then
print(signaturetext)
else
print("Error: Signature Not Found")
end
Re: My idea on how to make a working AI
How you make an AI depends on what type of game it is that you are making. I am going to assume that what you are trying to do is get an enemy to move to the player, if this is the case then your code does not work. In other terms, your code is as flawed as asking "Do we have enough fuel to drive from point A to point B if our car has room for 4 people?".
Your code is asking "Is the player position over 5". And if the player.x is over 5 then you move the enemy on both its X and Y axis. What it should be asking is "is the player position over the enemy position" and move the enemy accordingly. Check the Y position and X position separately and then move accordingly. I will try to give you an example of how to do it for the X position.
You will obviously have more than 1 enemy I assume, in that case you need to check the enemy table with a forloop.
Last I can say that using the code I posted about will make the enemy "jitter" when he reaches his final destination as the enemy will always overshoot the destination and keep going back and forth. So you need to add in so that it asks if the condition will be met even after the enemy has moved. Something like this:
Let me know if you didn't understand it. I also would recommend that you do not try to "teach" people how to do certain things when the code that you have is simply wrong. I know that you have no bad intentions and I am not trying to bash you for asking "noob questions" or anything, feel free to ask as much as you like. No question is too stupid.
Your code is asking "Is the player position over 5". And if the player.x is over 5 then you move the enemy on both its X and Y axis. What it should be asking is "is the player position over the enemy position" and move the enemy accordingly. Check the Y position and X position separately and then move accordingly. I will try to give you an example of how to do it for the X position.
Code: Select all
if player.x > enemy.x then
enemy.x = enemy.x + enemy.speed * dt
elseif player.x < enemy.x then
enemy.x = enemy.x - enemy.speed * dt
end
Last I can say that using the code I posted about will make the enemy "jitter" when he reaches his final destination as the enemy will always overshoot the destination and keep going back and forth. So you need to add in so that it asks if the condition will be met even after the enemy has moved. Something like this:
Code: Select all
if enemy.x > player.x and enemy.x + enemy.speed * dt > player.x then
enemy.x = enemy.x - enemy.speed
elseif enemy.x > player.x and enemy.x + enemy.speed * dt < player.x then
enemy.x = player.x
end
Last edited by Jeeper on Wed May 14, 2014 10:42 am, edited 1 time in total.
Re: My idea on how to make a working AI
Yeah i see what you mean. My main intension sort of like a proof of concept on a way to make the enemy move. To be honest, I seem to do stupid things durin the say but at night I'm more alert and actually think straight. I'll probaby take down this post. Actually yeah im gonna try to delete this.Jeeper wrote:How you make an AI depends on what type of game it is that you are making. I am going to assume that what you are trying to do is get an enemy to move to the player, if this is the case then your code does not work. In fact the code that you posted makes no sense on any level.
In other terms, your code is as flawed as asking "Do we have enough fuel to drive from point A to point B if our car has room for 4 people?".
Your code is asking "Is the player position over 5". And if the player.x is over 5 then you move the enemy on both its X and Y axis. What it should be asking is "is the player position over the enemy position" and move the enemy accordingly. Check the Y position and X position separately and then move accordingly. I will try to give you an example of how to do it for the X position.
You will obviously have more than 1 enemy I assume, in that case you need to check the enemy table with a forloop.Code: Select all
if player.x > enemy.x then enemy.x = enemy.x + enemy.speed * dt elseif player.x < enemy.x then enemy.x = enemy.x - enemy.speed * dt end
Last I can say that using the code I posted about will make the enemy "jitter" when he reaches his final destination as the enemy will always overshoot the destination and keep going back and forth. So you need to add in so that it asks if the condition will be met even after the enemy has moved. Something like this:
Let me know if you didn't understand it. I also would recommend that you do not try to "teach" people how to do certain things when the code that you have is simply wrong. I know that you have no bad intentions and I am not trying to bash you for asking "noob questions" or anything, feel free to ask as much as you like. No question is too stupid.Code: Select all
if enemy.x > player.x and enemy.x + enemy.speed * dt > player.x then enemy.x = enemy.x - enemy.speed elseif enemy.x > player.x and enemy.x + enemy.speed * dt < player.x then enemy.x = player.x end
http://xkcd.com/979/
Code: Select all
if signature = true then
print(signaturetext)
else
print("Error: Signature Not Found")
end
Re: Postdeleted.
Aww dude, don't delete your posts. This was some valuable information that future users of this forum may want to search for. You should see this xkcd comic: http://xkcd.com/979/luaiscool wrote:*Post Delete by Me, Luaiscool*
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Postdeleted.
Yeah, please don't delete posts once a problem is solved or forgotten. It just causes grief when others are looking for answers.
Re: Postdeleted.
I love that the alt text for that one basically describes a wiki.Inny wrote: Aww dude, don't delete your posts. This was some valuable information that future users of this forum may want to search for. You should see this xkcd comic: http://xkcd.com/979/
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Re: Postdeleted.
Well it's basically how StackOverflow works. Worked. The site can't be referred to as working anymore, but for all posts made before 2014, people were really good at marking down what they decided to be the correct answer.Lafolie wrote:I love that the alt text for that one basically describes a wiki.Inny wrote: Aww dude, don't delete your posts. This was some valuable information that future users of this forum may want to search for. You should see this xkcd comic: http://xkcd.com/979/
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 1 guest