• Hey! Register here to create your account, engage with the community, and talk about what is new!

particles and arrows.

Diceey

New member
Joined
Sep 20, 2021
Messages
15
Reaction score
0
Hey guys! Diceey here I have a couple questions for a game im making ;)

1: How can I add a spiral of particles that follow a projectile until its removed?
2:how can I detect where a projectile hits?

3:how can I get a sphere where a projectile hits?
4: how can I launch a player if there in said sphere,

Yes its a lot of questions but it will help a lot.

(also if its in cross-through I got it down)

-Thanks
Diceey
 
Last edited:
Solution
What a coincidence, I also had to code the same mechanics for my own game (this might not be the most efficient way to do it, but it works)

Projectile hit event()
{
if(projectile name equals "something") //only if you want weapons with different behaviors
{
//All the fancy stuff goes here (like sounds and particle effects)
Set a variable named sphereLocation to the arrow's location //where it hit the ground or player (it's a game value)
Set a variable named sphereRadius to the sphere's radius //3 for example
Set a variable named shooterName to the name of the shooter //(it's also a game value, only necessary if you dont want the shooter to be launched back)
//All of these are game...

Jimmy_The_Knight

Well-known member
Joined
Dec 28, 2020
Messages
67
Reaction score
31
What a coincidence, I also had to code the same mechanics for my own game (this might not be the most efficient way to do it, but it works)

Projectile hit event()
{
if(projectile name equals "something") //only if you want weapons with different behaviors
{
//All the fancy stuff goes here (like sounds and particle effects)
Set a variable named sphereLocation to the arrow's location //where it hit the ground or player (it's a game value)
Set a variable named sphereRadius to the sphere's radius //3 for example
Set a variable named shooterName to the name of the shooter //(it's also a game value, only necessary if you dont want the shooter to be launched back)
//All of these are game variables just to transfer the data to other parts of the code because DF doesn't support arguments yet
Select all players and start a process named ProjSphere //make sure it's set to 'for each in selection' or else it won't work!
}
}

Process ProjSphere()
{
if(the player (%default) is at most sphereRadius close to sphereLocation AND the name of the default player isn't shooterName)
{
Launch the player away from sphereLocation //put a negative value in the "Launch towards" player action
}
}

Hope this helps :D
 
Last edited:
Solution

stinkey

Forum adept
Joined
Sep 8, 2020
Messages
225
Reaction score
74
What a coincidence, I also had to code the same mechanics for my own game (this might not be the most efficient way to do it, but it works)

Projectile hit event()
{
if(projectile name equals "something") //only if you want weapons with different behaviors
{
//All the fancy stuff goes here (like sounds and particle effects)
Set a variable named sphereLocation to the arrow's location //where it hit the ground or player (it's a game value)
Set a variable named sphereRadius to the sphere's radius //3 for example
Set a variable named shooterName to the name of the shooter //(it's also a game value, only necessary if you dont want the shooter to be launched back)
//All of these are game variables just to transfer the data to other parts of the code because DF doesn't support arguments yet
Select all players and start a process named ProjSphere //make sure it's set to 'for each in selection' or else it won't work!
}
}

Process ProjSphere()
{
if(the player (%default) is at most sphereRadius close to sphereLocation AND the name of the default player isn't shooterName)
{
Launch the player away from sphereLocation //put a negative value in the "Launch towards" player action
}
}

Hope this helps :D
indentation
 

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,250
Reaction score
350
What a coincidence, I also had to code the same mechanics for my own game (this might not be the most efficient way to do it, but it works)

Projectile hit event()
{
if(projectile name equals "something") //only if you want weapons with different behaviors
{
//All the fancy stuff goes here (like sounds and particle effects)
Set a variable named sphereLocation to the arrow's location //where it hit the ground or player (it's a game value)
Set a variable named sphereRadius to the sphere's radius //3 for example
Set a variable named shooterName to the name of the shooter //(it's also a game value, only necessary if you dont want the shooter to be launched back)
//All of these are game variables just to transfer the data to other parts of the code because DF doesn't support arguments yet
Select all players and start a process named ProjSphere //make sure it's set to 'for each in selection' or else it won't work!
}
}

Process ProjSphere()
{
if(the player (%default) is at most sphereRadius close to sphereLocation AND the name of the default player isn't shooterName)
{
Launch the player away from sphereLocation //put a negative value in the "Launch towards" player action
}
}

Hope this helps :D
can't you Select All Players then Select Players By Condition{If Player Is Near} and then Filter Select By Name and use the NOT Arrow to remove the shooter?
 

Jimmy_The_Knight

Well-known member
Joined
Dec 28, 2020
Messages
67
Reaction score
31
can't you Select All Players then Select Players By Condition{If Player Is Near} and then Filter Select By Name and use the NOT Arrow to remove the shooter?
You're right, I knew that there was a much easier way to do it (maybe my approach is better for more complicated mechanics though)
 
Top Bottom