Difference between revisions of "Fixture:rayCast"

m
(I hope this explains the function better.)
Line 1: Line 1:
 
{{newin|[[0.8.0]]|080|type=method}}
 
{{newin|[[0.8.0]]|080|type=method}}
 
Casts a ray against the shape of the fixture.
 
Casts a ray against the shape of the fixture.
 
+
{{notice|There is a bug in [[0.8.0]] where the normal vector returned by this function gets scaled by [[love.physics.getMeter]].}}
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
x, y, fraction = Fixture:rayCast( x1, y1, x2, y2, maxFraction, childIndex )
+
xn, yn, fraction = Fixture:rayCast( x1, y1, x2, y2, maxFraction, childIndex )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
Line 12: Line 12:
 
{{param|number|x2|The x position of the ray end point.}}
 
{{param|number|x2|The x position of the ray end point.}}
 
{{param|number|y1|The y position of the ray end point.}}
 
{{param|number|y1|The y position of the ray end point.}}
{{param|number|maxFraction|The maximum distance the ray is going to travel as a number from 0 to 1.}}
+
{{param|number|maxFraction|The maximum distance the ray is going to travel as a factor of the input vector length.}}
 
{{param|number|childIndex (1)|The index of the child the ray gets cast against.}}
 
{{param|number|childIndex (1)|The index of the child the ray gets cast against.}}
 
=== Returns ===
 
=== Returns ===
{{param|number|x|The x position where the ray intersects with the shape.}}
+
{{param|number|xn|The x component of the normal vector of the edge where the ray hit the shape.}}
{{param|number|y|The y position where the ray intersects with the shape.}}
+
{{param|number|yn|The y component of the normal vector of the edge where the ray hit the shape.}}
{{param|number|fraction|The position on the input vector where the intersection happened as a number from 0 to 1.}}
+
{{param|number|fraction|The position on the input vector where the intersection happened as a factor of the input vector length.}}
 
== See Also ==
 
== See Also ==
 
* [[parent::Fixture]]
 
* [[parent::Fixture]]

Revision as of 14:55, 5 May 2012

Available since LÖVE 0.8.0
This method is not supported in earlier versions.

Casts a ray against the shape of the fixture.

O.png There is a bug in 0.8.0 where the normal vector returned by this function gets scaled by love.physics.getMeter.  


Function

Synopsis

xn, yn, fraction = Fixture:rayCast( x1, y1, x2, y2, maxFraction, childIndex )

Arguments

number x1
The x position of the ray starting point.
number y1
The y position of the ray starting point.
number x2
The x position of the ray end point.
number y1
The y position of the ray end point.
number maxFraction
The maximum distance the ray is going to travel as a factor of the input vector length.
number childIndex (1)
The index of the child the ray gets cast against.

Returns

number xn
The x component of the normal vector of the edge where the ray hit the shape.
number yn
The y component of the normal vector of the edge where the ray hit the shape.
number fraction
The position on the input vector where the intersection happened as a factor of the input vector length.

See Also


Other Languages