x


get the point directly above the raycast collision?

I'm casting a ray and its hitting the ground, and then I'm instantiating a unit at the collision point but I really want to instantiate it two or three units above the collision point, so how do I get that point?

ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Physics.Raycast (ray, hit, 2500);
midpoint = hit.point; 
mymoo = Instantiate(genmover, midpoint, Quaternion.identity);

I tried point.y+1 but that didn't you can't treat a hit.point like a transform.position I guess. maybe how do I break down the components of the hit.point to see it's x, y, and z of the vector3? because that's all it is a vector3.

more ▼

asked May 04 '10 at 12:25 AM

Jordan Miller 2 gravatar image

Jordan Miller 2
348 47 51 57

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

you can do myHit = hit.point

myHit+=Vector3.up*2

more ▼

answered May 04 '10 at 12:45 AM

spinaljack gravatar image

spinaljack
9.1k 18 31 92

thanks! that worked great!

May 04 '10 at 04:00 PM Jordan Miller 2
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2584
x1579
x599
x194
x133

asked: May 04 '10 at 12:25 AM

Seen: 1912 times

Last Updated: May 04 '10 at 12:25 AM