The Daily Click ::. Forums ::. Klik Coding Help ::. Automatic Doors?
 

Post Reply  Post Oekaki 
 

Posted By Message

vetmora120



Registered
  07/01/2010
Points
  273
14th August, 2010 at 14:04:00 -

Ok, say I want a number of doors with invisible objects over each of them that are slightly bigger. When the player is overlapping one of the invisible objects I want the door to open thats underneath the particular object.

How exactly would I achieve this? Or is there a better way to do it without using the invisible objects? If I'm not being specific enough please let me know.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
14th August, 2010 at 14:44:09 -

- Using detectors -
For this to work, you must be careful to have the same number of detectors as doors, and they must be correctly matched - ie. Oldest door with oldest detector... newest door with newest detector.

+ Always
-> Detector: Set Detect to 0

+ Player is overlapping detector
-> Detector: Set Detect to 1

+ Always
-> Door: Set Detect to Detect("Detector")

+ Detect of Door = 1
-> Open door...

+ Detect of Door = 0
-> Close door...



- Using range comparison -

+ Always
-> Door: Set Range to Sqr(((X("Player") - X("Door")) pow 2) + ((Y("Player") - Y("Door")) pow 2))

+ Range of Door <= OpenDist("Door")
-> Open door...

+ Range of Door > OpenDist("Door")
-> Close door...


The second method is simpler, but it's not as flexible.
eg. You couldn't easily make a door that only opens from one side.

Edited by Sketchy

 
n/a

vetmora120



Registered
  07/01/2010
Points
  273
14th August, 2010 at 15:05:38 -

Thanks heaps sketchy. I'm using the second method because I don't have to mess around with making sure I've got the exact amount of doors and detectors and such. Also it lowers the amount of objects.

I should just put you in the credits if I ever end up finishing this one

 
n/a

HorrendousGames

Sourpuss

Registered
  31/10/2009
Points
  481

VIP MemberEvil klikerGame Of The Week Winner
15th August, 2010 at 02:00:10 -


Originally Posted by Sketchy

The second method is simpler, but it's not as flexible.
eg. You couldn't easily make a door that only opens from one side.



Yes you can. All you need to put in the conditions is X pos of player is < or > pos of Door.

This simple code saves me from a heap of trouble, especially in dealing with direction based attacks.

EDIT: unless of course it's a top down game, then you'll have to take into consideration the origin of the door.

Edited by HorrendousGames

 
/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/-=?=-/
That Really Hot Chick
now on the Xbox Live Marketplace!

http://marketplace.xbox.com/en-US/Product/That-Really-Hot-Chick/66acd000-77fe-1000-9115-d80258550942

http://www.create-games.com/project.asp?view=main&id=2160
   

Post Reply



 



Advertisement

Worth A Click