playMaker

Author Topic: Raycast Sprites on the 3D space  (Read 6054 times)

Kothe

  • Junior Playmaker
  • **
  • Posts: 71
Raycast Sprites on the 3D space
« on: December 22, 2015, 04:39:32 AM »
Hi Everyone.
I used the Raycast action to raycast 3d objects with colliders, for a proyect using the
oculus rift. Now I need to raycast,from the head position, sprites. But the Rasycast do not detect Sprites, event with PolygonCollider 2D.
How can be detect Sprites when the user is looking at them ?

Thankyou
« Last Edit: December 22, 2015, 06:52:24 AM by Kothe »

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Raycast Sprites on the 3D space
« Reply #1 on: December 22, 2015, 08:04:19 AM »
You need to use raycast 2D - get from ecosystem. You can use a raycast 2d from a 3d object but it will only hit 2d colliders. So if you want to hit 2d + 3d then use raycast 2d in one fsm and use raycast 3d in another fsm (for example).

Kothe

  • Junior Playmaker
  • **
  • Posts: 71
Re: Raycast Sprites on the 3D space
« Reply #2 on: December 22, 2015, 10:22:45 AM »
From Ecosystem ?  raycast 2d It´s not in a package. A custom action ?

Kothe

  • Junior Playmaker
  • **
  • Posts: 71
Re: Raycast Sprites on the 3D space
« Reply #3 on: December 22, 2015, 10:35:18 AM »
You mean this Raycast 2d ?

But I can´t attach It right to follow the rotation of a cube p.e

Thx

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Raycast Sprites on the 3D space
« Reply #4 on: December 22, 2015, 12:52:27 PM »
Yes that one but you have to set the direction towards your target if that is what you need. For the moment it will only raycast in one direction with that setting.. it is the same principle as the 3d one. You need to watch the playmaker tutorial on raycasting as it all depends on your aim..

KellyRay

  • Full Member
  • ***
  • Posts: 170
Re: Raycast Sprites on the 3D space
« Reply #5 on: December 22, 2015, 01:10:58 PM »
Is your sprite meant to exist in a 3D space? If so, why not stick a 3d collider on it?

Kothe

  • Junior Playmaker
  • **
  • Posts: 71
Re: Raycast Sprites on the 3D space
« Reply #6 on: December 22, 2015, 01:23:41 PM »
I can´t make it work with the raycast 2d. A cube with this raycast...when I rotate the cube to look arround the Raycast do not do the rotations rights.
Quote
Is your sprite meant to exist in a 3D space? If so, why not stick a 3d collider on it?
Yes but... they have no mesh, and generate one mesh for each of them is not viable and cause its customs shapes cant asing a box collider.
« Last Edit: December 22, 2015, 01:50:47 PM by Kothe »

KellyRay

  • Full Member
  • ***
  • Posts: 170
Re: Raycast Sprites on the 3D space
« Reply #7 on: December 22, 2015, 02:08:46 PM »
What about putting an empty child under your sprite, and put all the collider info on that object?

Kothe

  • Junior Playmaker
  • **
  • Posts: 71
Re: Raycast Sprites on the 3D space
« Reply #8 on: December 22, 2015, 02:18:19 PM »
Sounds good but... the problem is the shape of the sprites, some stars, others circles,others leaves...so...what collider to match right ?

KellyRay

  • Full Member
  • ***
  • Posts: 170
Re: Raycast Sprites on the 3D space
« Reply #9 on: December 22, 2015, 02:25:23 PM »
I guess it if becomes super important you can match the shapes by modelings a 3d mesh in that shape. And use its a custom mesh collider.

I've never had to worry about the shape. Generally, boxes/circles/cylinders have worked for me regardless of the shape.

What is driving you to want to have the approximate shape? My thought is always, it is only a problem if it becomes a problem. If you can get away with just a general easy box collider, then I'd go that route.

Cant remember where heard this, but it changed the way I viewed all my game dev problems. Video games are just invisible boxes hitting more invisible boxes.

Kothe

  • Junior Playmaker
  • **
  • Posts: 71
Re: Raycast Sprites on the 3D space
« Reply #10 on: December 22, 2015, 03:11:14 PM »
Yes You right. I think the best choice its to make composed colliders from boxes colliders....

Thankyou

Kothe

  • Junior Playmaker
  • **
  • Posts: 71
Re: Raycast Sprites on the 3D space
« Reply #11 on: December 23, 2015, 07:42:14 AM »
EY!   I found this asset on the store and works so fine. Can create 2d colliders and convert them to 3d colliders.  Sprite Collider Generator
« Last Edit: December 23, 2015, 12:17:07 PM by Kothe »