The Daily Click ::. Forums ::. Klik Coding Help ::. Better Position Testing ?
 

Post Reply  Post Oekaki 
 

Posted By Message

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
26th May, 2008 at 18:16:17 -

Hello again ... I know what needs to be done to get the groupings to work efficiently and effectively now.
Problem is, once again, I don't know something needed to make it happen.
Any math wiz out there care to tell me:

How to Test the Distance between the Player Character and the Active Object Nearest to him ?


Image Edited by the Author.

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Deleted User
26th May, 2008 at 18:28:52 -

X POSITION OF ENEMY

MINUS

X POSITION OF PLAYER < 50 PIXELS - SHOOT BULLET

Something like that. If left decreases the x position, and right increases it that should work.



 

-Nick-

Possibly Insane

Registered
  24/11/2002
Points
  2468

VIP Member
26th May, 2008 at 18:46:04 -


Originally Posted by Matt Gayles
X POSITION OF ENEMY

MINUS

X POSITION OF PLAYER < 50 PIXELS - SHOOT BULLET

Something like that. If left decreases the x position, and right increases it that should work.




That only works in one direction.

Use the Clickteam Movement Controller, it can do all the hard work for you with its 'General expressions > Distance between two objects'

Just loop through the objects and find the closest one.

 
Project: Roller Coaster is on it's way!
http://www.projectrollercoaster.co.uk/
http://www.craftsncreatures.com

Deleted User
27th May, 2008 at 15:30:31 -

X POSITION OF

PLAYER

MINUS

X POSITION OF

ENEMY

< 50 PIXELS - SHOOT BULLET

Thats for the other side.

 

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
27th May, 2008 at 15:36:26 -

square root((X("Player") - X("Enemy"))² + (Y("Player") - Y("Enemy"))²) < Distance you need in pixels
:
Player - Look in direction of enemy
Player - Shoot an object

 
My signature is never too big!!!

Peblo

Custom ratings must be 50 characters or less

Registered
  05/07/2002
Points
  185

Game of the Week WinnerVIP MemberI'm on a Boat360 OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimePS3 OwnerIt's-a me, Mario!
I'm a Storm TrooperSonic SpeedStrawberryI like Aliens!Wii OwnerMushroomGhostbuster!
27th May, 2008 at 15:52:00 -

Yeah you actually have to use math in games, not pure conditions. Joe has the right answer.

 
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
27th May, 2008 at 16:17:59 -

Actually I made it so its the player shooting, rather than the enemy.

Same condition applies, just change the player in the actions bit to the enemy.

 
My signature is never too big!!!

Deleted User
27th May, 2008 at 16:21:50 -

What are you talking about? Adding and subtracting is math.

 

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
28th May, 2008 at 00:31:42 -

Thank you guys. I'll have to test the methods and see if they work for what I need.

Btw, whoever said that I need it for shooting ?
I simply need it to determine which object within a grouping of objects is to be acted upon by the group code.
I have a theory that this is a way to keep the TGF1 grouping system from glitching up when used with certain other code.
If you think you have a better method based upon what I have just said, then please add it here

I'm hoping for a solution customised to the situation. Thank you guys though. Matt and Joe, I really do appreciate the help.
Especially you Joe, cause the Math formula is what I'm looking for.

Here's my code. http://www.mediafire.com/?mmhtxinkmgn If you would be kind enough to form an exact solution, you'd make me and whoever else that happens upon this problem, very happy. Thanks Again !

http://www.mediafire.com/?mmhtxinkmgn


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?
   

Post Reply



 



Advertisement

Worth A Click