isTouchingGround: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments( \("local" or "global"\))?|Effects|Multiplayer Effects( \("local" or "global"\))?|Multiplayer Exe...)
m (Text replacement - "AgentRevolution" to "AgentRev")
 
(34 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command
{{RV|type=command
 
|game1= arma3
|version1= 0.50


| arma3
|0.50
|arg= global
|arg= global


|gr1= Object Manipulation
|gr1= Object Manipulation


| Returns true if object is touching the ground.
|descr= Returns true if object is touching the ground.


| '''isTouchingGround''' object
|s1= [[isTouchingGround]] object


|p1= object: [[Object]]
|p1= object: [[Object]]


| [[Boolean]]
|r1= [[Boolean]]


|x1= <sqf>if (isTouchingGround player) then { hint "Terraferma!" };</sqf>


|x1= <code>if ([[isTouchingGround]] [[player]]) then {[[hint]] "Terraferma!";};
|x2= A full "is safely parked" method for air, ground and water vehicles:
</code>
<sqf>
// get if a vehicle is properly parked - covers e.g helicopter landed on a building, boat (beached or not) and underwater or not submarine
// return false on null, disabled or destroyed vehicle
private _isSafelyParked = {
params [
["_vehicle", objNull, [objNull]], // 0: OBJECT - vehicle - a null object returns false
["_altitudeTolerance", 0.1, [0]], // 1: NUMBER - altitude tolerance - in metre
["_velocityTolerance", 0.01, [0]] // 2: NUMBER - velocity tolerance - in km/h
];


if (not canMove _vehicle) exitWith { false }; // returns false for null as well


| [[underwater]]
if (_vehicle isKindOf "Ship") then
{
// surfaceIsWater getPosASL _vehicle // a beached boat is fine
velocity _vehicle params ["_velX", "_velY"];
sqrt (_velX * _velX + _velY * _velY) < _velocityTolerance // only 2D speed matters (think waves)
&& {
getPosASLW _vehicle < _altitudeTolerance // underwater submarines are OK
|| { getPos _vehicle select 2 < _altitudeTolerance } // beached boat
};
}
else
{
// over -a- ground and not over ocean
(isTouchingGround _vehicle || {
getPosASLW _vehicle select 2 >= _altitudeTolerance // not in water
&& { getPos _vehicle select 2 < _altitudeTolerance }
})
&& { vectorMagnitude velocity _vehicle * 3.6 < _velocityTolerance }
}
};


| |MPBEHAVIOUR=  
objectParent player call _isSafelyParked;
</sqf>
 
|seealso= [[underwater]]
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= AgentRev
<!-- Note Section BEGIN -->
|timestamp= 20140601012300
|text= If you are using this command as a validation method, it should not be the sole thing you are checking for, as the result is often inaccurate.
For example, it returns false for some helicopters when landed on the roof of certain buildings, and it always returns false for boats, even if they are beached.
}}


<!-- Note Section END -->
{{Note
</dl>
|user= Demellion
 
|timestamp= 20160929082800
<h3 style='display:none'>Bottom Section</h3>
|text= In addition to previous statement: That behaviour is true, simply because [[isTouchingGround]] applied to a player unit (or any unit) is frozen to a last state when unit enters vehicle.
{{GameCategory|arma3|New Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on June 1, 2014 - 01:23 (UTC)</dd>
<dt class="note">[[User:AgentRevolution|AgentRevolution]]</dt>
<dd class="note">
If you are using this command as a validation method, it should not be the sole thing you are checking for, as the result is often inaccurate. For example, it returns false for some helicopters when landed on the roof of certain buildings, and it always returns false for boats, even if they are beached.
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on September 29, 2016 - 08:28 (UTC)</dd>
<dt class="note">[[User:Demellion|Demellion]]</dt>
<dd class="note">
In addition to previous statement: That behaviour is true, simply because '''isTouchingGround''' applied to a player unit (or any unit) is frozen to a last state when unit enters vehicle.
To get proper return from this command you should go for units [[vehicle]]:  
To get proper return from this command you should go for units [[vehicle]]:  
<code>_var = isTouchingGround player // Unreliable
<sqf>
_var = isTouchingGround (vehicle player) // Pretty reliable
_var = isTouchingGround player; // unreliable
</code>
_var = isTouchingGround (vehicle player); // pretty reliable
</dd>
</sqf>
</dl>
}}
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Pierre MGI
<dd class="notedate">Posted on November 10, 2016 - 20:57 (UTC)</dd>
|timestamp= 20161110205700
<dt class="note">[[User:Pierre MGI|Pierre MGI]]</dt>
|text= This command returns always true if the falling object is attached to some other object with the [[attachTo]] command, like for vehicle air drop with parachute.
<dd class="note">
}}
This command returns always true if the falling object is attached to some other object with the command attachTo, like for vehicle air drop with parachute.
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Gippo
<dd class="notedate">Posted on April 26, 2017 - 20:02 (UTC)</dd>
|timestamp= 20170426200200
<dt class="note">[[User:Gippo|Gippo]]</dt>
|text= Be aware: it is not reliable on remote objects.
<dd class="note">
}}
Be aware: it is not reliable on remote objects.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 23:07, 4 May 2024

Hover & click on the images for description

Description

Description:
Returns true if object is touching the ground.
Groups:
Object Manipulation

Syntax

Syntax:
isTouchingGround object
Parameters:
object: Object
Return Value:
Boolean

Examples

Example 1:
if (isTouchingGround player) then { hint "Terraferma!" };
Example 2:
A full "is safely parked" method for air, ground and water vehicles:
// get if a vehicle is properly parked - covers e.g helicopter landed on a building, boat (beached or not) and underwater or not submarine // return false on null, disabled or destroyed vehicle private _isSafelyParked = { params [ ["_vehicle", objNull, [objNull]], // 0: OBJECT - vehicle - a null object returns false ["_altitudeTolerance", 0.1, [0]], // 1: NUMBER - altitude tolerance - in metre ["_velocityTolerance", 0.01, [0]] // 2: NUMBER - velocity tolerance - in km/h ]; if (not canMove _vehicle) exitWith { false }; // returns false for null as well if (_vehicle isKindOf "Ship") then { // surfaceIsWater getPosASL _vehicle // a beached boat is fine velocity _vehicle params ["_velX", "_velY"]; sqrt (_velX * _velX + _velY * _velY) < _velocityTolerance // only 2D speed matters (think waves) && { getPosASLW _vehicle < _altitudeTolerance // underwater submarines are OK || { getPos _vehicle select 2 < _altitudeTolerance } // beached boat }; } else { // over -a- ground and not over ocean (isTouchingGround _vehicle || { getPosASLW _vehicle select 2 >= _altitudeTolerance // not in water && { getPos _vehicle select 2 < _altitudeTolerance } }) && { vectorMagnitude velocity _vehicle * 3.6 < _velocityTolerance } } }; objectParent player call _isSafelyParked;

Additional Information

See also:
underwater

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
AgentRev - c
Posted on Jun 01, 2014 - 01:23 (UTC)
If you are using this command as a validation method, it should not be the sole thing you are checking for, as the result is often inaccurate. For example, it returns false for some helicopters when landed on the roof of certain buildings, and it always returns false for boats, even if they are beached.
Demellion - c
Posted on Sep 29, 2016 - 08:28 (UTC)
In addition to previous statement: That behaviour is true, simply because isTouchingGround applied to a player unit (or any unit) is frozen to a last state when unit enters vehicle. To get proper return from this command you should go for units vehicle:
_var = isTouchingGround player; // unreliable _var = isTouchingGround (vehicle player); // pretty reliable
Pierre MGI - c
Posted on Nov 10, 2016 - 20:57 (UTC)
This command returns always true if the falling object is attached to some other object with the attachTo command, like for vehicle air drop with parachute.
Gippo - c
Posted on Apr 26, 2017 - 20:02 (UTC)
Be aware: it is not reliable on remote objects.