View previous topic :: View next topic |
Author |
Message |
chess123mate Beginner Poster
Joined: 06 Feb 2008 Posts: 40 Location: Canada
|
Posted: Mon Jul 07, 2008 11:12 pm Post subject: "Script" Command/Function Request: Finding the rea |
|
|
Name: Command/Function for finding the true size of a brick in World coordinates
Brief Description: I need to find the real size of a brick, so that if it's rotated, the "real" size changes accordingly. The simplest example is if a 2x1x4 brick is rotated 90 degrees (left/right, doesn't matter), then it is now a 4x1x2 brick. Of course, this function/command needs to have the ability to take absolutely any angle, including vertical angles.
Wiki link: http://wiki.roblox.com/index.php?title=Scripting#CFrame
Note that some of the commands there, though I tried to use them, didn't seem to exist... [or didn't do anything significant]
Place It'll be used in: Antz Warz, account "chess123mate2", as an ERRC Project. I need it so that the builders of the project don't have to make all the bricks non-angled, lol... the ants need to know how to get around an object when they hit it, or if they want to get to it.
Roblox Forums link: http://www.roblox.com/Forum/ShowPost.aspx?PostID=1705058
Thanks for any help you can give me. I hoped there was an easier solution than trig to do this, but I'm unsure. If anyone knows the trig, I'd greatly appreciate showing me how to use it.
chess123mate |
|
Back to top |
|
|
kiddietron Site Admin
Joined: 06 Feb 2008 Posts: 797 Location: On Roblox
|
Posted: Mon Jul 07, 2008 11:56 pm Post subject: |
|
|
This is difficult but I think I've seen something like this. If I find something out I'll get back to you. _________________ �Kiddietron
�Phailing at making a signature
Free Money here just sign up and click away.
http://bux.to/?r=kiddietron
Spam is for noobs.
|
|
Back to top |
|
|
Anaminus Beginner Poster
Joined: 08 Feb 2008 Posts: 17 Location: Location: Location: Location: Location: Location:
|
Posted: Tue Jul 08, 2008 8:33 pm Post subject: |
|
|
I don't quite know what you want, but I think I know something that could work. Try this out:
Code: | part = workspace.Part
o = part.CFrame
e = true
part.Changed:connect(function(p)
if p == "CFrame" then
if not e then return end
e = false
local v = part.CFrame:vectorToWorldSpace(part.Size)
part.Size = Vector3.new(math.abs(v.x),math.abs(v.y),math.abs(v.z))
part.CFrame = o
e = true
end
end) |
It's not in any function form, but maybe you can get something from it. I don't really know how it works, but I remember seeing 'rotation' and 'Vector3' in the CFrame article. After giving a few tries at the vectorToWorldSpace function, it apparently worked.
?-Anaminus-? _________________ ?-Anaminus-?
^^You're probably seeing this twice because I typed in my signature >_< |
|
Back to top |
|
|
chess123mate Beginner Poster
Joined: 06 Feb 2008 Posts: 40 Location: Canada
|
Posted: Tue Jul 08, 2008 10:20 pm Post subject: |
|
|
Wow... I'm not sure that works, but it sure is interesting
The wiki didn't say how to use the functions like vectorToWorldSpace, it just kind of said "there, now you figure it out"
Unfortunately, I can't check it out right now (time + on a bad computer), but I will as soon as I can
That script honestly is confusing It seems to re-adjust it's size, if I understand it correctly, based on it's angle and thus it's WorldSpace coordinates. Cool!
EDIT: Yes, thanks! This is exactly what I need! The thing about the wiki is it didn't tell you what the parameters needed to be. Someone should really rewrite those.
The command I needed was:
size=part.CFrame:vectorToWorldSpace(part.Size)
[and then optionally]
size=Vector3.new(math.abs(size.x), math.abs(size.y), math.abs(size.z))
It does the calculations I was looking for. If you rotate a brick, obviously the brick's size stays the same, but if you looked at it from the World's point of view (without angle), it would look like a diamond-like shape with a completely different size. I don't know if that helped describe this any.
Thanks again,
chess123mate |
|
Back to top |
|
|
kiddietron Site Admin
Joined: 06 Feb 2008 Posts: 797 Location: On Roblox
|
Posted: Tue Jul 08, 2008 11:04 pm Post subject: |
|
|
Wow, sorry I couldn't help but this looks like a promising function. Better than doing all the trig. _________________ �Kiddietron
�Phailing at making a signature
Free Money here just sign up and click away.
http://bux.to/?r=kiddietron
Spam is for noobs.
|
|
Back to top |
|
|
|