Document raycasting
This commit is contained in:
parent
fa20631e7b
commit
c68ee69c9b
@ -27,6 +27,9 @@
|
||||
|
||||
#include "Rigidbody.h"
|
||||
|
||||
/**
|
||||
Holds information about the results of a raycast
|
||||
*/
|
||||
struct RaycastResult {
|
||||
bool hit;
|
||||
Vector3 position;
|
||||
@ -54,6 +57,12 @@ public:
|
||||
*/
|
||||
void Step(float delta);
|
||||
|
||||
/**
|
||||
Performs a raycast
|
||||
@param from the start location of the raycast
|
||||
@param to the end location of the raycast
|
||||
@returns a RaycastResult with data collected by the raycast
|
||||
*/
|
||||
RaycastResult Raycast(const Vector3 &from, const Vector3 &to);
|
||||
private:
|
||||
static World* world;
|
||||
|
@ -37,7 +37,7 @@ function onkey(key, code, action, mod)
|
||||
local res = couch.World.GetWorld():Raycast(camera_transform.position,
|
||||
camera_transform.position + camera_transform:Forward() * 100.0)
|
||||
if (res.hit) then
|
||||
res.object:ApplyImpulse(res.normal * -100.0)
|
||||
res.object:ApplyImpulse(camera_transform:Forward() * 100.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user