playMaker

Author Topic: Shooting a raycast through an object?  (Read 1654 times)

DIamod

  • Playmaker Newbie
  • *
  • Posts: 17
Shooting a raycast through an object?
« on: April 02, 2019, 03:35:26 AM »
Hi, I am having trouble understanding how to make sure that a raycast always shoots in relation to the object it's firing from.

I have a unique camera setup that the camera never moves, only a reticle overlay does.

My scene looks like this the green line represents the expected raycast direction and the orange the actual raycast direction
https://i.imgur.com/b3GWCHs.png


I came up with the solution of making the raycast source (reticle) always point towards a 2nd object before passing through it.

A top-down view would look like this


I cannot find anything in the ecosystem for this, so any help would be appreciated.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Shooting a raycast through an object?
« Reply #1 on: April 02, 2019, 05:22:14 AM »
Hi.
The image link does not work.

could you also show how you set you fsm/state/actions?

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Shooting a raycast through an object?
« Reply #2 on: April 02, 2019, 05:28:36 AM »
Maybe you can turn the raycasting game object, rather than the raycast itself, towards a target?

DIamod

  • Playmaker Newbie
  • *
  • Posts: 17
Re: Shooting a raycast through an object?
« Reply #3 on: April 02, 2019, 05:41:05 AM »
Thanks for the reply, both images are showing for me I can try a different image host, however.

Here is my FSM https://ibb.co/m9RP9fv

the problem is that as the object rotates in the scene it's always firing in the same direction. The following is a gif showing the debug ray, as you can see its always fireing north, rather than the direction that the crosshair is facing.

« Last Edit: April 02, 2019, 05:47:40 AM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Shooting a raycast through an object?
« Reply #4 on: April 02, 2019, 05:52:25 AM »
Hi.
I think imgur is having issues at the moment.

On the raycast action. do you have 'Space' set to self?

DIamod

  • Playmaker Newbie
  • *
  • Posts: 17
Re: Shooting a raycast through an object?
« Reply #5 on: April 02, 2019, 05:54:37 AM »
I figured it out thanks!
Changed space to Self
from game object to itself
and a direction of Y -1

Not sure why but this combination seems to be working  :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Shooting a raycast through an object?
« Reply #6 on: April 02, 2019, 06:07:03 AM »
hi, space Self will use the object rotation.
space world will use the set direction Vector no mater what rotation the object has.


so if you would set a direction y 1, in world space it will always send upward no matter if the object is rotated to a certain degrees.

if object is rotated 180 degrees in z, then the raycast would be downwards.