playMaker

Author Topic: Problem with raycast normal  (Read 3215 times)

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Problem with raycast normal
« on: September 21, 2018, 01:39:54 PM »
Hello everyone,

I'm trying to create a bullet hole with a raycast hit.

I have a state in which the "raycast" action that creates the raycast and stores the informations.

In the following state I have a "create object" action that contains my "bullet hole" object and gets the position of hit raycast ("hit point") and rotation ("hit normal").

But when I pull the raycast my bullet holes are positioned correctly on vertical walls but not on floors.

The bullet holes still remains positioned vertically.

Have I forgotten something?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6607
    • jinxtergames
Re: Problem with raycast normal
« Reply #1 on: September 22, 2018, 06:18:03 AM »
Hi.
What action do you use to set the rotation?

I think you can try using "Quaternion Look Rotation"

By the way you should also look into 'pooling' then instead of creating.
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #2 on: September 22, 2018, 06:56:39 AM »
Hi djaydino,

I do not use any action to set the rotation, just create object and in it I set my "hit normal" info in "rotation" field.
I can not see any "pooling" action in PM. What do you mean?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6607
    • jinxtergames
Re: Problem with raycast normal
« Reply #3 on: September 22, 2018, 07:35:49 AM »
Hi.
Did you try using "Quaternion Look Rotation" instead of the rotation field?

Pooling is a solution to use instead of creating and destroying (which is expensive cpu wise See this link for an explanation why you should use pooling.)
Pooling will create a preset amount of the object (disabled) and reuse them when needed

There are several pool asset on the asset store, but there is also a simple one on the Ecosystem called 'Pooler'
Also in one of the next PlayMaker updates there will be a build in pool system included.
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #4 on: September 22, 2018, 08:13:11 AM »
What you is to put a quaternion look rotation action before the create object action?
And in the direction I set the hit normal info then store the result. And after, in the create object action I set the result of quaternion look rotation in the rotation field of create object?

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #5 on: September 22, 2018, 08:42:46 AM »
Ok, so I downloaded the Pooler in the ecosystem. I put the action "Quaternion Look Rotation" before the Pooler, in direction I put the "Hit Normal" of my raycast and I store the result (hitNormal, as quaternion).

Then I put a "Pooler Pool" in which I have my Bullet Hole prefab. Then a Spawn Pooler, in Position I have my Raycast hit point, but in rotation I do not really know what to put.
I tried with the Hit Normal of the raycast but it does not work.
So the Quaternion Look Rotation is useless here.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6607
    • jinxtergames
Re: Problem with raycast normal
« Reply #6 on: September 22, 2018, 12:59:53 PM »
Hi.
After you pool the object you should store the object and then use the "Quaternion Look Rotation" with the stored object.

I looked to a c# tutorial doing this :



So he is doing a raycast,
Then instantiate (where he should pool)

Then uses the hit point + hit normal multiplied by 0.00001 (this is to set it a little bit in front of the hit position, so you wont get flickering images)
and Quaternion.LookRotation with the hit normal.

I  will see if i can make a sample after the weekend.
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #7 on: September 22, 2018, 04:08:26 PM »
thank you djaydino you are great  :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6607
    • jinxtergames
Re: Problem with raycast normal
« Reply #8 on: September 23, 2018, 10:01:48 AM »
Hi.
Did you get it to work?
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #9 on: September 24, 2018, 06:44:20 AM »
Hi djaydino,

nop it doesn't work :(
I can't take the stored object in the Quaternion Look Rotation.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6607
    • jinxtergames
Re: Problem with raycast normal
« Reply #10 on: September 24, 2018, 11:42:06 AM »
Hi.
I tried a setup and i got it to work,
I will try to make a video tomorrow.
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #11 on: September 24, 2018, 12:18:16 PM »
ohhh cool!
can't wait lol

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #12 on: September 26, 2018, 05:23:31 AM »
Hi djaydino,

did you make the video? I'm so stuck :(

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6607
    • jinxtergames
Re: Problem with raycast normal
« Reply #13 on: September 26, 2018, 08:35:24 AM »
Hi.
Sorry i had to record in bits and pieces due a lot of construction work going on here.

I am editing at the moment and will try to finish it today :)
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Problem with raycast normal
« Reply #14 on: September 26, 2018, 09:09:59 AM »
You do not have to say sorry lol.

Really a big thank you for helping us here and I know that sometimes we are annoying :)

But thanks again to you :)