of     1   

xiaoxiao181
#154927653Friday, January 30, 2015 3:17 AM GMT

when i want 1 part to orbit another part I can do something like this: for i = 1, 360 do PartB.CFrame = PartA.CFrame * CFrame.Angles(0, i, 0) + PartA.CFrame.lookVector * 5 wait() end presto, orbit. but what if I want to simply find a fixed Vector around a part? Im building a tower defense game and I want my earth tower to launch a boulder at a target, then when the boulder hits its target, the boulder disappears spawning 3 little rocks that arc out in random directions around the Y axis. The main boulder is no problem and neither is the arcing. its finding the random vectors after it hits that im having issues with. i just dont know how to do it
xiaoxiao181
#154935974Friday, January 30, 2015 6:57 AM GMT

Part = script.Parent function Find() local Point = nil Point = Part.CFrame * CFrame.Angles(0, math.random(1, 360), 0) print(Point) end Find() That didn't work at all. I kept getting results with 12 numbers I don't know what that means but I know it's not what I wanted. I can't post the results either because apparently numbers break roblox's rules.
xiaoxiao181
#154946046Friday, January 30, 2015 4:22 PM GMT

bump
xiaoxiao181
#154951904Friday, January 30, 2015 7:19 PM GMT

bump
TrustMeImRussian
#154952402Friday, January 30, 2015 7:32 PM GMT

Have it launch one brick with gyro maybe, then wait(x) and have it clone into two more bricks and have them launch at a different vector?
xiaoxiao181
#154952869Friday, January 30, 2015 7:45 PM GMT

I appreciate that but I'm not looking for suggestions. I already have everything planned out. I'm just looking for help.
xiaoxiao181
#154958023Friday, January 30, 2015 9:17 PM GMT

bump
xiaoxiao181
#154960301Friday, January 30, 2015 9:51 PM GMT

I'm basically trying to do this again: http://www.roblox.com/Forum/ShowPost.aspx?PostID=145655075 The problem being that I can't find the script now. Idk where I put it and the codepad page is gone.
xiaoxiao181
#154964702Friday, January 30, 2015 10:50 PM GMT

bump
morash
#154965221Friday, January 30, 2015 10:58 PM GMT

The 12 numbers that your function is printing out is a CFrame. If you do CFrame.lookVector, it will return a Vector3 giving the direction it's facing in radians.
xiaoxiao181
#154997560Saturday, January 31, 2015 7:27 AM GMT

well now i know. bump
xiaoxiao181
#155010919Saturday, January 31, 2015 3:33 PM GMT

bump
xiaoxiao181
#155046048Saturday, January 31, 2015 10:58 PM GMT

bump
xiaoxiao181
#155050449Saturday, January 31, 2015 11:47 PM GMT

bump
xiaoxiao181
#155056079Sunday, February 01, 2015 12:45 AM GMT

bump
xiaoxiao181
#155080549Sunday, February 01, 2015 5:54 AM GMT

bump
xiaoxiao181
#155108681Sunday, February 01, 2015 5:25 PM GMT

bump
xiaoxiao181
#155117234Sunday, February 01, 2015 7:11 PM GMT

bump
woot3
#155120058Sunday, February 01, 2015 7:43 PM GMT

If the point where the boulder hit is x and I assume that you want to spawn them at a given point around x in a spherical fashion. function rndNeg() return math.random(1, 2) == 1 and 1 or -1 end function getRandomVector(x) local dir = Vector3.new(math.random()*rndNeg(), math.random()*rndNeg(), math.random()*rndNeg()) return x + dir.unit end I believe that'll do it well enough.
xiaoxiao181
#155121526Sunday, February 01, 2015 8:00 PM GMT

I'll try to explain this as clear as I can. Apparently I didn't explain it well enough. That's my fault and I take responsibility for that. I blame nobody else. The boulder is launched in an arc at the target using CFrame, nothing else. An anchored part CFramed at the target. No gyros, no body force. Once the boulder hits the target, a local variable takes note of the CFrame of the boulder, then deletes it. This next part is where the help comes in. Around the Y axis, that means horizontally, flat in a circle. At a set, non changeable distance of 5 studs, 3 random vectors are chosen in this circle around the CFrame that was recorded before the boulder was deleted. That's what I'm trying to get. Just 3 randomly generated points around the Y axis of the recorded CFrame. After that it's a simple matter if spawning 3 smaller rocks and arcing them at those points. thats the easy part. Now, I could use a really UGLY hack where I spawn 3 parts and rotate them using CFrame.Angles and then move them using lookVector, then recording their CFrames, but I would prefer not to use such an ugly workaround. Not to mention the fact that it would take slightly longer to perform the attack if I did that. The animations must run smoothly or else I can't continue building.
xiaoxiao181
#155122013Sunday, February 01, 2015 8:05 PM GMT

However, I might be able to work something out using your algorithm. Lemme try something and I'll get right back to ya.
xiaoxiao181
#155123363Sunday, February 01, 2015 8:21 PM GMT

Nope, didn't work. It always returns the same point.
woot3
#155131206Sunday, February 01, 2015 9:50 PM GMT

Oh, that's easy. Let's assume cf was the CFrame of the boulder and r is how far away the new position is from the center. local r = 5 local randomPoint = cf * CFrame.Angles(0, math.random()*2*math.pi, 0) * CFrame.new(r, 0, 0)
xiaoxiao181
#155135876Sunday, February 01, 2015 10:39 PM GMT

I've been fooling around with it and it does work, but it seemed a bit confusing to understand until I realized what was going on there. CFrame.Angles(0, math.random()*2*math.pi, 0) is no different from CFrame.Angles(0, math.rad(math.random(1, 360)), 0) which means I was originally close but I failed to realize I had to extend the distance by adding a CFrame.new after the angles. Thank you so much. I can get back to building my game now. I don't know why this was so hard.

    of     1