playMaker

Author Topic: Raycast [SOLVED]  (Read 1195 times)

marvoc

  • Playmaker Newbie
  • *
  • Posts: 37
Raycast [SOLVED]
« on: January 30, 2019, 10:11:54 AM »
Hello again,
 thanks for previews answers. Now I have a different issue. I'd like to raycast from camera to moving unit, and length of raycast should be longer then only this distance.
https://drive.google.com/open?id=1njerDdGBtIGCqu49COWVXFfRBULK7bCQ
Moving units - gray circles
Raycast - as two lines

When I open Raycast rollout, I know about vector3 (camera center) to project from, but Im missing here something like Target (defined as Vector3). So in this case I wouldn't need vector3 direction vector.
https://hutonggames.fogbugz.com/default.asp?W492

Its possible to add something like this to raycast, or there is another way how to do it? ;) I think that "Vector3 direction" is already some defined line comapre to only point "Vector3".

Mayby completly bad question ;)
« Last Edit: March 08, 2019, 03:33:27 PM by marvoc »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Raycast
« Reply #1 on: January 30, 2019, 10:33:27 PM »
Hi.
I can't test right now, but this is what comes into my head :

Have a empty child on the camera and do the raycast from this object (space : self)
You will need to test what is the forward direction and set that direction.
(The thru direction will be managed by the Empty Child)

Before you do the raycast :
Use 'look at' and set the empty child as Gameobject, also set the target object.

Use Get distance to get the distance for the empty child and the target.
Then with the result from the distance, you can use "add Float"
and add the desired distance you want the raycast to go behind the object.

Then use the result from "distance+add Float" to the raycast Distance variable and do the raycast.

marvoc

  • Playmaker Newbie
  • *
  • Posts: 37
Re: Raycast
« Reply #2 on: March 08, 2019, 03:32:01 PM »
Thank you for your answer.
So, on the end, I made it in different way. Im using position of camera as one Vector3, then using second Vector3 as target position.
With this two Vectors Im Subtracting with Vector3 Operator. And result is Vector which Im using for Direction within Raycast, where Camera is source of Raycast.