IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Post mod/code requests in the Mod Requests topic

Post mod releases in the Mod Showroom

Read the Modding Rules BEFORE posting!

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 Ray casting/Collision detection?

 
LostDerp  
Posted: Wednesday, Feb 1 2012, 11:16
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Nov 27, 2011

XXXXX



Is there anyway to do any trace to find where there's collision within a line of sight? Or is there anyway to get the collision at a certain point?
PM
  Top
 

 
jitsuin  
Posted: Wednesday, Feb 1 2012, 16:23
Quote Post


Meat Popsicle
Group Icon
Group: BUSTED!
Joined: Dec 6, 2011

us.gif

XXXXX



jydnjydrbut

This post has been edited by jitsuin on Friday, Feb 3 2012, 23:41
PMMSNXbox Live
  Top
 

 
thaCURSEDpie  
Posted: Saturday, Feb 11 2012, 03:01
Quote Post


GTA:IV scripter
Group Icon
Group: Members
Joined: Jul 1, 2007

XXXXX



There is no cheap way I know of. There are a number of ways though, some of which I've tried. The best I've come up with:

Asynchronous method
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.

Pros:
- asynchronous, thus non-blocking
- no search-length / distance limit

Cons:
- 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)
PM
  Top
 

 

0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG