Camera::getCoord: Difference between revisions
MrPancakers (talk | contribs) mNo edit summary |
|||
| Line 7: | Line 7: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
// | function pointingAt(distance) { | ||
const camera = mp.cameras.new("gameplay"); // gets the current gameplay camera | |||
let position = camera.getCoord(); // grab the position of the gameplay camera as Vector3 | |||
let direction = camera.getDirection(); // get the forwarding vector of the direction you aim with the gameplay camera as Vector3 | |||
let farAway = new mp.Vector3((direction.x * distance) + (position.x), (direction.y * distance) + (position.y), (direction.z * distance) + (position.z)); // calculate a random point, drawn on a invisible line between camera position and direction (* distance) | |||
let result = mp.raycasting.testPointToPoint(position, farAway, [1, 16]); // now test point to point | |||
return result; // and return the result ( undefined, if no hit ) | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{Camera_definition_c}} | {{Camera_definition_c}} | ||
[[Category:Clientside API]] | [[Category:Clientside API]] | ||
[[Category:TODO: Example]] | [[Category:TODO: Example]] | ||
Revision as of 14:53, 19 December 2018
Syntax
camera.getCoord();
Required Arguments
Return value
- Vector3
Example
function pointingAt(distance) {
const camera = mp.cameras.new("gameplay"); // gets the current gameplay camera
let position = camera.getCoord(); // grab the position of the gameplay camera as Vector3
let direction = camera.getDirection(); // get the forwarding vector of the direction you aim with the gameplay camera as Vector3
let farAway = new mp.Vector3((direction.x * distance) + (position.x), (direction.y * distance) + (position.y), (direction.z * distance) + (position.z)); // calculate a random point, drawn on a invisible line between camera position and direction (* distance)
let result = mp.raycasting.testPointToPoint(position, farAway, [1, 16]); // now test point to point
return result; // and return the result ( undefined, if no hit )
}
See also
- Functions:
- Camera::Camera
- Camera.animatedShake
- Camera.attachTo
- Camera.attachToPedBone
- Camera.destroy
- Camera.detach
- Camera.doesExist
- Camera.getAnimCurrentPhase
- Camera.getCoord
- Camera.getDirection
- Camera.getFarClip
- Camera.getFarDof
- Camera.getFov
- Camera.getNearClip
- Camera.getRot
- Camera.getSplinePhase
- Camera.isActive
- Camera.isInterpolating
- Camera.isPlayingAnim
- Camera.isRendering
- Camera.isShaking
- Camera.playAnim
- Camera.pointAt
- Camera.pointAtCoord
- Camera.pointAtPedBone
- Camera.setActive
- Camera.setActiveWithInterp
- Camera.setAffectsAiming
- Camera.setAnimCurrentPhase
- Camera.setCoord
- Camera.setDebugName
- Camera.setDofFnumberOfLens
- Camera.setDofFocusDistanceBias
- Camera.setDofMaxNearInFocusDistance
- Camera.setDofMaxNearInFocusDistanceBlendLevel
- Camera.setDofPlanes
- Camera.setDofStrength
- Camera.setFarClip
- Camera.setFarDof
- Camera.setFov
- Camera.setInheritRollVehicle
- Camera.setMotionBlurStrength
- Camera.setNearClip
- Camera.setNearDof
- Camera.setParams
- Camera.setRot
- Camera.setShakeAmplitude
- Camera.setUseShallowDofMode
- Camera.shake
- Camera.stopPointing
- Camera.stopShaking
- Camera.setDofParam
- Camera.getDofParam
- Properties: