SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
I am trying to move a player from a blast in the direction relative to where the blast was and how close by them it was. The problem is with direction. How do I aim the direction the players will be launched from where the blat occurred?
#help |
|
AIexandxrJoin Date: 2015-05-29 Post Count: 1708 |
body position
|
|
NikkulaiJoin Date: 2014-06-01 Post Count: 946 |
Try using lookVector
|
|
SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
How would I use body position in this? :L |
|
Skylake_XJoin Date: 2014-07-16 Post Count: 303 |
is it an explosion or a custom scripted explosion
R$22,792 |
|
NikkulaiJoin Date: 2014-06-01 Post Count: 946 |
Do something like this:
blast.Touched:connect(function(hit)
nikk = Instance.new("BodyVelocity", blast)
nikk.maxForce = Vector3.new(math.huge, math.huge, math.huge)
nikk.velocity = blast.CFrame.lookVector*100
wait(.5)
nikk:Remove()
end)
|
|
SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
You obviously do not understand. I mean when there is an explosion, I want players to be flown away from it with realistic direction. |
|
QuasiduckJoin Date: 2008-09-28 Post Count: 2437 |
Your direction would be,
(player.Position - explosion.Position).Unit*SpeedValue
Ideally, players closer to the explosion will get pushed back further.
So you could use as input for some velocity class:
(player.Position - explosion.Position).Unit*MaxSpeedValue/math.ceil((player.Position - explosion.Position).magnitude)
|
|
NikkulaiJoin Date: 2014-06-01 Post Count: 946 |
Wow i try to help out and dont even get a thanks. What a bummer.
But the thing is i never really understood what you meant by "a blast in the direction relative to where the blast was"
So im sorry if i got confused because you said blast and not explosion.
|
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
mutiplier = 10 -- how strong the force will be
function Boom()
character.PrimaryPart.Velocity = (explosionPosition-char.PrimaryPart.Position).unit*multiplier
end
|
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
@Quasi
It's the unit of explosionPos-playerPos not playerPos-explosionPos
That would send them flying towards the explosion (implosion?) XD |
|
QuasiduckJoin Date: 2008-09-28 Post Count: 2437 |
No, that's wrong.
@Soybeen.
Think of it geometrically,
you start at explosionPos and travel along the vector -explosionPos to arrive at the origin.
Then you travel along the vector playerPos to now arrive at the player's position.
So you've gone from the explosion, to the global origin to the player position.
This is the same as if you just went straight from the explosion pos to the player pos.
Which is the direction we want. |
|
SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
I figured it out... mostly. I just got the difference in x, y, and z and used that.
#help |
|
|
isnt there a property in explosions that determines the force of the explosion? that force pushes stuff away, including players if they don't die
why won't u use that?
#code error("you're*") |
|
SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
Because I am making a custom explosion.
#help |
|
SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
Okay the problem now is increasing the force the blast exerts on you depending on close you are to it without changing the direction where it is implied. It has been bugging me as it only increases as you go further out rather than closer.
#help |
|
SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
And no, (player.Position - explosion.Position).Unit*MaxSpeedValue/math.ceil((player.Position - explosion.Position).magnitude) doesn't work. You clearly do not understand the dilemma, which is partially my fault for not fully explaining. the problem is converting this into just the right amount of force to push someone back at a realistic angle while still increasing the closer they get. That is my problem.
#help |
|
RerumuJoin Date: 2014-10-11 Post Count: 1489 |
CFrame.new(explosionLocation, torso.Position).lookVector
that's your direction thanks |
|
RerumuJoin Date: 2014-10-11 Post Count: 1489 |
Velocity = CFrame.new(explosionLocation, torso.Position).lookVector * distanceFromExplosion * playerMass;
if you want everything to be accounted for |
|
SimpleSetJoin Date: 2017-02-25 Post Count: 165 |
Thank you so much, I now understand how you get the distance Diamond. One small problem remains is how can I make the force a bit stronger to the outer parts without drastically raising the force when you get closer?
#help |
|
RerumuJoin Date: 2014-10-11 Post Count: 1489 |
Make it an exponential function. |
|
QuasiduckJoin Date: 2008-09-28 Post Count: 2437 |
My solution does work. However, it doesn't rely on force as you wanted.
It relies on updating the velocity.
This is mainly because I see an explosion as an instantaneous force which isn't maintained enough for acceleration to occur. Therefore, setting only the velocity to a correct degree would suffice (where other forces like friction/air resistance would slow it down). It also DOES take into account pushing back closer players further.
|
|