playMaker

Author Topic: Object hitted[SOLVED]  (Read 168 times)

miguelfanclub

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
Object hitted[SOLVED]
« on: August 31, 2017, 10:43:35 AM »
Hi,

raycasting forward from camera on a specific layer. Storing hit on a game object variable. It works, meaning that I get what has been hitted on the variable.

Now, what would be the best option to know that the hitted object knows he has been hitted?

Is there a "am i been hitted" action?

I know I can do it by a Get Name Action and then do a compare string to check if the object has been hitted but Ive been told comparing string is a really bad practice, specially if its every frame.

What would be the best practice here?

cheers

« Last Edit: September 04, 2017, 12:18:20 AM by jeanfabre »

miguelfanclub

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
Re: Object hitted
« Reply #1 on: September 01, 2017, 11:57:05 AM »
Im really stuck on this.

I need to change the way I interact with objects from triggers to raycasting.

I have no way to know how to achieve "on exit" and "on stay".
Im trying now using raycast 2 with hit / no hit events trying to make a loop to simulate those behaviours but I cant make it work.

Not so much info in the forums.


tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Object hitted
« Reply #2 on: September 01, 2017, 09:51:42 PM »
Hi, there is no action such as this. This is not a function of raycast. However, I might do it this way.

Raycast tells you which object it has hit. Save that object as a variable. When the ray hits a new object, send a global event to that object. Something like "On Global Enter". Make sure to setup this global variable on the object. (Any objects you want to be hit).

Then that object will know it has been hit.

Save that object variable to a second variable (so it doesnt get removed when you get to the next object). Use it to compare. Compare if object has changed. (If it is not the same anymore, then you know you have moved to the next object. Send the old object a global custom event for exit. Send the new object your on global enter). If it hasent changed, do nothing.

You can put those objects you want hit on a specific layer. So the ray cast will only hit those objects. That way, you dont send any extra un-necessary events to other objects that are not setup for it. (You can send events to them, but its just a waste).

Let me know if you understood that.

miguelfanclub

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
Re: Object hitted
« Reply #3 on: September 02, 2017, 05:51:39 AM »
Dude!
DUDE!!

Thanks!!!!!