playMaker

Author Topic: Smooth Look At Direction Not Finishing  (Read 1873 times)

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Smooth Look At Direction Not Finishing
« on: July 29, 2019, 03:34:52 PM »
Hi there!

I'm making a simple AI that walks around and when it encounters a wall, it should turn away from it. I made a setup with a raycast which waits for an obstacle before sending an even to this state:



Right now I'm experimenting with the operators so I'm not sure what to go with yet but with this setup the character is turning away from the obstacle when the raycast hits using that Smooth Look At Direction action. Unfortunately, that action is not finishing so the AI is unable to do another raycast for new walls.

I thought maybe the action gets a V3 result that it is unable to accomplish so it gets stuck but I don't know how to test for that and I'm left wondering if I'm going about this the right way to begin with.

I'd really appreciate some help so if you have any clue or maybe some advice, I'd love to hear from you!

Thanks :)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: Smooth Look At Direction Not Finishing
« Reply #1 on: July 29, 2019, 07:47:59 PM »
Im not really good with this, but i ever made a detector by raycast for a character to navigate.
I made 3 raycast, straight in front of character and the other 2 is about 30/45 degree from the first ray to the left and right. When collide, check the first first:P and then the other two.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Smooth Look At Direction Not Finishing
« Reply #2 on: July 30, 2019, 06:21:37 AM »
Hi,

make sure you don't use the built in events for other purposes than why they were created.

 The FINISH event should not be used inside actions like that, instead make a new event "DONE" or something and plug that.

 While it sometimes work, you will end up eventually with a bug where PlayMaker will fire the FINISH event because all actions on the state have finished, but you'll expect an action to fire that same event, so it could be bugging your logic.

Bye,

 Jean

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Re: Smooth Look At Direction Not Finishing
« Reply #3 on: July 30, 2019, 07:43:29 AM »
[...]
I made 3 raycast, straight in front of character and the other 2 is about 30/45 degree from the first ray to the left and right. [...]

Thanks for the suggestion! I never thought of that. For this project though, I want to keep the amount of raycasts to a minimum so hopefully I can get buy with just the one :)

[...]
 The FINISH event should not be used inside actions like that, instead make a new event "DONE" or something and plug that.
[..]

Hey Jean!

I didn't know that about using the built-in FINISH event so thanks for the advice. I just changed it to a custom event like you suggested but the state still won't resolve itself and go back to the previous state like I want. It gets stuck like this:



To bruit force it, I gave the state a wait action for 3 seconds then send the DONE event which works for now but I would still like to know what I'm doing wrong.

Thanks again!

--

For anyone curious, after putting in the timer, I found that my little setup for picking a direction and rotating in my original post didn't work. Instead I'm getting the Normal Direction of the raycast hit and rotating to that which works well. Later I might change it to check the object's tag before choosing to rotate to get more control.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Smooth Look At Direction Not Finishing
« Reply #4 on: July 30, 2019, 09:03:12 AM »
Hi,

 well, to me it seems that because the look at smooth is not instant, it's normal that you don't get the action to send the event straight away but only when it actually reached out. no?

 Bye,

 Jean

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Re: Smooth Look At Direction Not Finishing
« Reply #5 on: July 30, 2019, 10:13:01 AM »
[...] because the look at smooth is not instant, it's normal that you don't get the action to send the event straight away but only when it actually reached out[...]

Yeah, that could very well be the case. To check I would need to find the character's direction and compare that with the normal direction I get from the raycast. I'm not sure how to do that though. Either way, just doing a wait for 3 seconds may be a good solution after all in case the action is ever unable to resolve for other unforeseeable reasons.

Thanks for the help :)