• Add local vector?
    2 replies, posted
Is there a way to add onto a vector with a local vector? To make things clearer, I have players play death animations and then a bloodpool spawns, like this: if robot == false and Corpse:IsValid() then timer.Simple( Corpse:SequenceDuration(), function() ParticleEffect( "bloodpool", player:GetLocalPos()+Vector(50,0,-10), Angle( 0, 0, 0 ) ) end) end (if you were wondering, the -10 is so the bloodpool properly spawns on the floor, and i get the player's position instead of the corpse entity's position because it's slightly more reliable) Anyway, you can see I try to add a vector so that the bloodpool appears under the corpse rather than at their feet or something. While it works fine at some angles, at others it doesn't and the vector I add seems to be relative to the world and not to the corpse. Basically, my question is: Can I add a vector onto an entity's position and have the vector be relative to the entity somehow? I haven't found anything on this. Or perhaps I'm incredibly slow. Anyway, thanks for reading.
GetLocalPos will only return a different result for parented entities, which players are (usually) not. Entity/LocalToWorld is what you are looking for: if robot == false and Corpse:IsValid() then timer.Simple( Corpse:SequenceDuration(), function() if player:IsValid() then ParticleEffect( "bloodpool", player:LocalToWorld( Vector( 50, 0, -10 ) ), Angle( 0, 0, 0 ) ) end end) end
You're a hero, take a diamond
Sorry, you need to Log In to post a reply to this thread.