PlayMaker Help & Tips > PlayMaker Help

Raycast2D at a game object instead of direction

(1/2) > >>

Krillan87:
Hi,

I've searched the forum and googled a bit on this action that do not seems to exist.

A lot of the time I would like my Raycasts2D to to try to hit another game object in the scene, like a very simple line of sight. Right now I always just put a "look at-action" and then raycast from that game object but I feel like this is such a common usage of the raycast that I feel like it should be a integrated part of the standard action. An option to either use "Direction" or "Gameobject" when declaring where the raycast should be cast.

Maybe this is not the case because there is a solution already (using the look at as I described) but I would the updated action.

(Maybe this should be in the Suggest action subforum and not in the help?)

/Christian

ransomink:
A raycast is essentially a laser beam fired towards a specific direction. It is an API method in Unity, so it's not Playmaker specific. If you want to raycast at a game object I'd continue to use the Look At action to point toward the game object and cast in that direction. Or you can get the target game object's position, find the direction by subtracting the target position from the origin, then cast in the resulting direction. There are other methods as well

I can see a custom action with an option to supply a game object. it would get the direction using the supplied game object and the origin position...

jeanfabre:
Hi,

You are right, there are no actions ( as far as I know), that deduce the direction to shoot a raycast from a target.

Your Look at trick is good in my opinion, I would stick to it actually, because it gives you more control in the end.

Is it your typical need where you want your player to fire towards the mouse?

Bye,

 Jean

Krillan87:

--- Quote from: jeanfabre on November 21, 2019, 02:02:13 AM ---Hi,

You are right, there are no actions ( as far as I know), that deduce the direction to shoot a raycast from a target.

Your Look at trick is good in my opinion, I would stick to it actually, because it gives you more control in the end.

Is it your typical need where you want your player to fire towards the mouse?

Bye,

 Jean

--- End quote ---


Hi,

I see. No, this is a 2d platform game and the 2d raycasts are often from the enemy to see if the player is in line of sight. So this is not a big issue, I was just curious if there was an 2-in-1-action that did the trick or if anyone else had the same request.

jeanfabre:
Hi,

 uhm... how many enenmies do you have? lookat is expensive, so in your case, it might make sense that I create a custom actions so that you don't waiste perfs on that.

Bye,

 Jean

Navigation

[0] Message Index

[#] Next page

Go to full version