Post mod/code requests in the Mod Requests topic.
Post mod releases in the Mod Showroom.
Read the Modding Rules BEFORE posting!
Free mod hosting from GTANet, simply login with your GTAForums account details
GTANet's modding wiki
Ray casting/Collision detection?
Posted 01 February 2012 - 11:16 AM
Posted 01 February 2012 - 04:23 PM
Edited by jitsuin, 03 February 2012 - 11:41 PM.
Posted 11 February 2012 - 03:01 AM
Create a new class which inherits the GTA.Timer class. Give it a GTA.Object property - this will be used for the col-detection. Upon creating the tracer object, create a small object (CJ_PROP_GRENADE works well) at the specified startposition. Give the object a specific velocity, the direction of which should be equal to the search direction, but the size (speed) should always be constant.
In the OnTickEvent of the class, set the object's velocity to the specified one. However, before you do so, check the current velocity against the 'ideal' velocity. If the velocity has changed too much (slowed down, change in velocity-direction), there has been a collision.
Save the object's coordinates and call the callback specified when creating the tracer object.
- asynchronous, thus non-blocking
- no search-length / distance limit
- relatively slow (~0.5 s / search: unsuitable for realtime tracing).
Something else you could try is hooking DirectX and using some D3D function (though I don't have a lot of experience with that. Hooking D3D is pretty easy though)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users