Game Development Community

possible to detect if standing near water tile ? [solved]

by Jeff Yaskus · in Torque 3D Professional · 01/19/2011 (1:28 am) · 2 replies

I'm making an outdoor game, where the player needs to "drink" water.

Is it possible to script a method to see if the player is standing in front of a water tile ?
Then I can "enable" the button/action to "drink" ...

Also, hoping to use the same approach to allow them to "eat" wild plants which I place as static meshes into the game level. I would assume the same method could be applied in that case as well...

Is there a standard approach for player interaction with the environment in T3D ??

#1
01/19/2011 (2:56 am)
Steve Acaster has a melee weapon resource that utilizes short-distance ray casting; with a bit of surgery this can be gutted to cause an event to trigger based on what ObjectType (Such as WaterObjectType) the player is looking at when a button is pressed. I'm sure there's a better approach, but I'm just getting into Torque script myself, starting with weapons.

http://www.torquepowered.com/community/resources/view/20273
#2
04/14/2011 (4:01 pm)
I used the on_collision() to detect when the character is touching a plant (static item) ... and for water tiles I used the code in servers/player.cs which already checks for player entering or leaving water.

Its rather simple, but works!