playMaker

Author Topic: Shotgun Spread?[SOLVED]  (Read 1765 times)

Bipolar

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Shotgun Spread?[SOLVED]
« on: November 22, 2017, 03:03:28 PM »
Hi.

I made a shotgun, now I need to know how to emit multiple raycast in different direction within a certain range.

Some help?
Thanks!
« Last Edit: November 28, 2017, 11:25:59 AM by Bipolar »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4613
    • View Profile
    • jinxtergames
Re: Shotgun Spread?
« Reply #1 on: November 23, 2017, 02:20:15 AM »
Hi,
Try a search on the Ecosystem.
Look for Random Vector

You could also use 2 random floats and the use set vector 3 xyz

For looping this a certain times, you can use 'iterate'


Bipolar

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Shotgun Spread?
« Reply #2 on: November 23, 2017, 02:43:01 PM »
Hi,
Try a search on the Ecosystem.
Look for Random Vector

You could also use 2 random floats and the use set vector 3 xyz

For looping this a certain times, you can use 'iterate'

The raycast to emit should be 24 at shoot, because the weapon uses two ammunition caliber 12.

So Iterate is needed to emit multiple raycast at time?

There should be a rule within too: the random emission of raycast has to have a maximum and minimum spread index, this to avoid rare case of 24 bullets shot too near each other.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4613
    • View Profile
    • jinxtergames
Re: Shotgun Spread?
« Reply #3 on: November 24, 2017, 06:45:59 AM »
Hi,
Maybe have a certain range for each raycast, else you need to place each raycast position into an array an after each raycast you need to check if it is to close to another.

maybe use 4 fsms (top left/topright/bottomleft/bottomright) to split the raycasts.

or instead of random have preset positions in a list and get those(randomly per group) to do the raycasts?

Bipolar

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Shotgun Spread?
« Reply #4 on: November 25, 2017, 07:22:29 AM »
Hi,
Maybe have a certain range for each raycast, else you need to place each raycast position into an array an after each raycast you need to check if it is to close to another.

maybe use 4 fsms (top left/topright/bottomleft/bottomright) to split the raycasts.

or instead of random have preset positions in a list and get those(randomly per group) to do the raycasts?

Nope, the first emission mode is what i want to implement. So i need to split raycasts in 4 groups?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4613
    • View Profile
    • jinxtergames
Re: Shotgun Spread?
« Reply #5 on: November 25, 2017, 02:49:50 PM »
Hi,
If you split in four and still do random positions, you still need to do the math so that they are not to close to each other.

I would use 6 arrays and make preset Raycast positions, so for each index you have a group of 6 Raycasts (6 arays)

Then select a random group index and use for each side (top left/top right/bottom left/bottom right) which would give some extra randomness than using 24 arrays and preset all of them at once.

You might need to use 'world: Self' or use a Vector 3 add, to position for each side.

I also think that preset positions are better for performance.

Btw, i am only suggesting things :)

Best is to play around and see what fits best for your project.

Bipolar

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Shotgun Spread?
« Reply #6 on: November 27, 2017, 02:11:00 PM »
Hi,
If you split in four and still do random positions, you still need to do the math so that they are not to close to each other.

I would use 6 arrays and make preset Raycast positions, so for each index you have a group of 6 Raycasts (6 arays)

Then select a random group index and use for each side (top left/top right/bottom left/bottom right) which would give some extra randomness than using 24 arrays and preset all of them at once.

You might need to use 'world: Self' or use a Vector 3 add, to position for each side.

I also think that preset positions are better for performance.

Btw, i am only suggesting things :)

Best is to play around and see what fits best for your project.

I don't know, I think the raycast preset is the 'eastiest' way to do this.
I'm not a programmer, I'm a graphic designer, I'm using Playmaker because I don't want to learn languages.

So as you saied it's possible add a little random influence in the preset metod?
It should be good.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4613
    • View Profile
    • jinxtergames
Re: Shotgun Spread?
« Reply #7 on: November 27, 2017, 04:35:45 PM »
Hi.
Yes. for each side you can make a random int between 0 and the number for groups.
I do think it might be easier to use Array maker than the standard array.

You can find the array maker on the ecosystem and you can find some tutorials on the User Tutorials wiki page

But i will try to make a sample this week how to set this up.

Bipolar

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Shotgun Spread?
« Reply #8 on: November 28, 2017, 11:26:52 AM »
Hi.
Yes. for each side you can make a random int between 0 and the number for groups.
I do think it might be easier to use Array maker than the standard array.

You can find the array maker on the ecosystem and you can find some tutorials on the User Tutorials wiki page

But i will try to make a sample this week how to set this up.

Thanks!
I'm going to check the link. :)

Just another tip:
how can i set up a raycast preset which starts from the same point and "splits" itself increasing its range with the distance?
« Last Edit: November 28, 2017, 12:03:17 PM by Bipolar »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4613
    • View Profile
    • jinxtergames
Re: Shotgun Spread?[SOLVED]
« Reply #9 on: November 28, 2017, 01:39:16 PM »
Hi,
i am not sure what you mean?

That a raycast would go a certain distance and then split up?
if so then you would do a single raycast and then on the end point where you want it to split up you need to get that position and then do new rayscasts from that position.

Bipolar

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Shotgun Spread?[SOLVED]
« Reply #10 on: November 28, 2017, 04:38:31 PM »
Sorry, I did a mistake with 'Split', I confused you.

I mean how can I to make raycasts starting from the same point and after this set their rotation from the point them started?

I know about the Vector3 origin point of a raycast, but to rotate it so I can make my custom raycast presets?

I hope it is undestandable, I have some difficult to transpose my language meaning to english language.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4613
    • View Profile
    • jinxtergames
Re: Shotgun Spread?[SOLVED]
« Reply #11 on: November 29, 2017, 03:15:25 PM »
Hi,
You need to set the direction and space to self.

i will try to make a sample tomorrow.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14684
  • Official Playmaker Support
    • View Profile
Re: Shotgun Spread?[SOLVED]
« Reply #12 on: November 29, 2017, 11:21:43 PM »
Hi,

 I did a sample on firing bullets on the Ecosystem: search for "bullet" and filter by samples and you;'ll find a "Firing2d Bullet" which will show you how to do this basics of firing.

 Bye,

 Jean

Bipolar

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Shotgun Spread?[SOLVED]
« Reply #13 on: December 01, 2017, 08:37:57 AM »
Hi,

 I did a sample on firing bullets on the Ecosystem: search for "bullet" and filter by samples and you;'ll find a "Firing2d Bullet" which will show you how to do this basics of firing.

 Bye,

 Jean

Thanks! I'll check.  ;)