generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: CFraming question.

Previous Thread :: Next Thread 
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
19 Jun 2015 12:10 AM
Let's say I'm standing a short distance away from Part A.

I want to place Part B five studs away from Part A, in the direction of my torso.

How might I go about this? I'm familiar with CFraming, but this one's a head-scratcher.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
19 Jun 2015 12:17 AM
well

local charactercframe = LocalPlayer.Character:GetModelCFrame()

now you're going to get part A's cframe

local partAcframe = PartA.CFrame

now you're going to want to make a new CFrame pointing at charactercframe.

local newCFrame = CFrame.new(partAcframe.p, charactercframe.p) --http://wiki.roblox.com/index.php?title=Cframe#Constructors @CFrame.new(Vector3 position, Vector3 point)

now set partB's CFrame to this and multiply it by an offset.

local offset = CFrame.new() --i'm not sure which local axis you're going to move the part on so i'll let you do that
partB.CFrame = newCFrame * offset

pretty sure that explains it?

-=Robo=-
Report Abuse
Geomaster is not online. Geomaster
Joined: 05 Jul 2008
Total Posts: 1480
19 Jun 2015 12:23 AM
Sorry, figured I should've clarified a bit more.

Let's say that all three positions are variable and can change at any given time.
What I'm out to do is create a weapon ability that causes a trail of icicles
to sprout from the ground and follow the target.

In this situation, Part A would be the last icicle created, Part B is the new icicle, and
it appears a set distance away from the last one in the direction of wherever the player
currently is.

So I'm not sure I'll know the exact offset at any given time.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
19 Jun 2015 12:26 AM
That sounds like a neat tool.
Yeah, you'd use the same logic, if you need to know how to detect the offset, you could probably use a common offset and just repeat execution until the icicles reach the target.

-=Robo=-
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
19 Jun 2015 12:33 AM
Do you mean direction that the torso is facing or the direction of vector from partA to torso?
Direction torso is facing:
partB.Position = partA.Position + (5 * torso.CFrame.lookVector)

Direction of partA to torso:
partB.Position = partA.Position + (5 * (torso.Position - partA.Position).unit)
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
19 Jun 2015 12:34 AM

If I am at 5,5,5

and from the center point the part needs to be away from the same amount
we would just take the center point and translate it negative our position from it.

local Part = game.Workspace.Part
local You = game.Workspace.Player1.Torso
local Center = Vector3.new(0,0,0)

while wait() do
Part.CFrame = CFrame.new(Center) * CFrame.new(-You.Position.X, 0, -You.Position.Z)
end
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
19 Jun 2015 12:37 AM
ahh, I wish I understood vectors.
can't wait for school to start <3 lol

-=Robo=-
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
19 Jun 2015 12:48 AM
Vectors are easy.

They are a position that can be represented as a direction.

They are x y and z coordinates.

Looking at a basic x and y grid would make more sense about translating (or moving) points of a vector around.

Vector3.new(5,5,5) - Vector3.new(1,1,1) is the different between these two vectors.

We can take the difference vector and use Pythagorean theorem to draw right triangles and use the C for the distance between these two points...

or use magnitude since you don't want to do all these calculations

I have never dabbled in using .Unit (the direction) of a vector.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image