Maintenance - We're currently working on things and you might experience some issues. Should be wrapped up soon!

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

6
Raycast starting infront of the object
Post Body

Hello, so I not sure how to fix this, and after 1 hour of googling and testing different things, I rather jsut ask you guys.

So, I have a parent-object, with the children: a car (3d mesh) and some other child-objects.
Now I am trying to cast a RayCast starting infront of the object, but I've tried:
thisUnitVector Vector3.forward

But the RayCast starts in the middle of the car-object, therefor the first collider it hits, is itself. Therefor I can't detect if the RayCast hits anything else. (I can't use different layers, as there are several car-models in the game at the same time.. its a RTS)

I just can't get it to start infront of the car...
Sure, I can just add thisUnitVector.z = 2.0f; But that is just not a good solution.

Ultimately I want the RayCast to start at the front (edge) of the boxcollider! Because I don't want the object to detect itself.

Thanks, Simon

Comments

Use a layer mask to have the raycast not detect the layer that the car is on.

Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
7,686
Link Karma
5,956
Comment Karma
1,687
Profile updated: 2 days ago
Solo Developer

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 years ago