Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre 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:
(http://i.imgur.com/HjIBxq2.png)
Bye,
Jean
-
Thats exactly what i need, it works great!
Thanks a lot!
-
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
-
Hi,
you can do that already, the action "GetRaycastHitInfo" is compatible with my SphereCast action :)
bye,
Jean
-
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
-
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?
-
I've used this for AI/Pathfinding (modified it a bit though), been really consistent.
-
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.
-
Do you have colliders on the other objects you're trying to hit?
-
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?
-
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.
-
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 ...
-
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
-
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.
-
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 (http://hutonggames.com/playmakerforum/index.php?topic=5406.msg34223#msg34223) ) in a package for the AI beta stuff.
-
Thanks!
-
just use my new best friend action: "next frame event"
I love this thing ;D
-
Good tip! Thanks!
Anyway, spherecast every frame solved my camera wall clipping issue in TPP game. It's pretty much rock solid, camera never goes through walls, no matter what angle you try.
-
If SphereCast hits multiple objects, how could I store these objects to variables? "Get Raycast Hit Info" has only 1 "Game Object Hit" field. I want to store the hit objects into variables to perform operations on them.
-
Hi,
This action implement the version where it returns the first hit, to access all collisions, we should have a new action using SphereCastAll.
http://docs.unity3d.com/ScriptReference/Physics.SphereCastAll.html
Please bump this next week, I'll if I can do it.
Bye,
Jean
-
thats fun to use!
-
The action don't work anymore :( I'm with playmaker 1.8.3 and unity 5.4
Could anyone test it too so we can see if it's only for me or if the code needs an update ?
-
Hi,
Tested and it works, what exactly doesn't work?
Bye,
Jean