playMaker

Author Topic: SphereCast  (Read 15256 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
SphereCast
« on: April 24, 2013, 01:52:27 AM »
Hi,

 following a thread, please find a regular SphereCast action, performing like RayCast only casting a sphere instead of a ray.

The action is available on the Ecosystem:



 Bye,

 Jean
« Last Edit: January 13, 2017, 02:12:19 AM by jeanfabre »

doppelmonster

  • Full Member
  • ***
  • Posts: 157
    • Grinder Games
Re: SphereCast
« Reply #1 on: April 24, 2013, 05:42:06 AM »
Thats exactly what i need, it works great!

Thanks a lot!

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: SphereCast
« Reply #2 on: April 28, 2013, 10:47:52 AM »
Hey Jean,

Thanks very much for sharing with everyone.

Just one thing I think this is missing is the ability to store the Hit target as a GameObject var. I am terrible at coding so would you be able to update your code with that? I think quite a few people would use it.

Cheers
Terry 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: SphereCast
« Reply #3 on: April 29, 2013, 02:57:33 PM »
Hi,

 you can do that already, the action "GetRaycastHitInfo" is compatible with my SphereCast action :)

bye,

 Jean

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: SphereCast
« Reply #4 on: April 24, 2014, 09:29:55 AM »
Hey,

I just got around to using this and I seem to be having a bit of trouble. The cast only seems to return a hit every now and then. Not sure if anyone else has seen these issues?

Cheers
Terry

doppelmonster

  • Full Member
  • ***
  • Posts: 157
    • Grinder Games
Re: SphereCast
« Reply #5 on: April 24, 2014, 09:33:31 AM »
I use it in 2 games and it works pretty good. are you sure you have your transforms right and the capsule is pointing in the right direction?
« Last Edit: April 24, 2014, 10:49:28 AM by doppelmonster »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: SphereCast
« Reply #6 on: April 24, 2014, 09:51:01 AM »
I've used this for AI/Pathfinding (modified it a bit though), been really consistent.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: SphereCast
« Reply #7 on: April 24, 2014, 09:53:00 AM »
Ah thats good to hear, means I can put it down to my own incorrect use of it and try and work out what im doing wrong.

Im not sure about the direction but that sounds like it might be the issue. To test it I just made the radius and distance huge. I was thinking that this would then  make a big sphere that would easily hit something but it still doesn't. So maybe there is a transform thing that im not getting.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: SphereCast
« Reply #8 on: April 24, 2014, 09:59:57 AM »
Do you have colliders on the other objects you're trying to hit?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: SphereCast
« Reply #9 on: April 24, 2014, 10:06:31 AM »
Yeah I have colliders. There sphere hits sometimes but then other times it doesnt, I think this must be a direction related issue. As the object the sphere starts from is moving on a random path.

I think the way I understand sphere casting might be incorrect. I currently have the direction set to 1,1,1. As I assume that it will create a sphere outwards to the size and radius that I have specified. im not actually sure if this is the case now.

So does the radius dictate the radius of the starting sphere or the radius that the sphere will end up at the end of the frame?




 

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: SphereCast
« Reply #10 on: April 24, 2014, 10:21:03 AM »
Spherecast is just a thick raycast. It doesn't go out in a spherical shape, or in all directions.

The 'direction' variable is a vector3, so if it was 0,0,1 then it would be straight forward as Z is forward.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

doppelmonster

  • Full Member
  • ***
  • Posts: 157
    • Grinder Games
Re: SphereCast
« Reply #11 on: April 24, 2014, 10:47:41 AM »
spherecast creates a capsule in the direction of the vector. with radius you can adjust the thickness of the capsule. Like lane said usually you keep the transform at 0,0,1 to shoot the capsule in the z direction. So 1,1,1 is an odd direction.

If you need a "real" sphere cast you would use a sphere collider as trigger or a lookAt action with a distance check  ...

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: SphereCast
« Reply #12 on: April 25, 2014, 07:03:10 AM »
Hey Guys,

Thanks a lot for the help and clearing that up. It makes a whole lot more sense now that I understand how it actually works :D

Sphere collider seems like a great fit what what I need.

Thanks again

Kubold

  • Full Member
  • ***
  • Posts: 112
Re: SphereCast
« Reply #13 on: May 19, 2014, 04:24:52 AM »
Hmm, if this is a "thick raycast", can it have an option to fire every frame or every other frame etc. (normal Raycast does it)? Right now it goes off just once.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: SphereCast
« Reply #14 on: May 19, 2014, 07:29:27 AM »
It might have been for performance concerns. Casts have a tendency to get expensive sometimes. I've used spherecasts on the flight AI stuff i'm doing per-frame and haven't really noticed any issues, though. I have a spherecast action every frame ( click ) in a package for the AI beta stuff.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D