playMaker

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

Franck

  • Junior Playmaker
  • **
  • Posts: 84
    • View Profile
Problem with raycast normal
« on: September 21, 2018, 10:39:54 AM »
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: 4705
    • View Profile
    • jinxtergames
Re: Problem with raycast normal
« Reply #1 on: September 22, 2018, 03: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.

Franck

  • Junior Playmaker
  • **
  • Posts: 84
    • View Profile
Re: Problem with raycast normal
« Reply #2 on: September 22, 2018, 03: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: 4705
    • View Profile
    • jinxtergames
Re: Problem with raycast normal
« Reply #3 on: September 22, 2018, 04: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.

Franck

  • Junior Playmaker
  • **
  • Posts: 84
    • View Profile
Re: Problem with raycast normal
« Reply #4 on: September 22, 2018, 05: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: 84
    • View Profile
Re: Problem with raycast normal
« Reply #5 on: September 22, 2018, 05: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: 4705
    • View Profile
    • jinxtergames
Re: Problem with raycast normal
« Reply #6 on: September 22, 2018, 09:59:53 AM »
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.

Franck

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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4705
    • View Profile
    • jinxtergames
Re: Problem with raycast normal
« Reply #8 on: September 23, 2018, 07:01:48 AM »
Hi.
Did you get it to work?

Franck

  • Junior Playmaker
  • **
  • Posts: 84
    • View Profile
Re: Problem with raycast normal
« Reply #9 on: September 24, 2018, 03: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: 4705
    • View Profile
    • jinxtergames
Re: Problem with raycast normal
« Reply #10 on: September 24, 2018, 08:42:06 AM »
Hi.
I tried a setup and i got it to work,
I will try to make a video tomorrow.

Franck

  • Junior Playmaker
  • **
  • Posts: 84
    • View Profile
Re: Problem with raycast normal
« Reply #11 on: September 24, 2018, 09:18:16 AM »
ohhh cool!
can't wait lol

Franck

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

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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4705
    • View Profile
    • jinxtergames
Re: Problem with raycast normal
« Reply #13 on: September 26, 2018, 05: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 :)

Franck

  • Junior Playmaker
  • **
  • Posts: 84
    • View Profile
Re: Problem with raycast normal
« Reply #14 on: September 26, 2018, 06: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 :)