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 » Scripting Helpers
Home Search
 

Re: Simple tree growth

Previous Thread :: Next Thread 
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Dec 2013 09:23 PM
I have this script I engineered for SB.
Its designed to grow trees.
It works fine, but the problem is that it spawns trees at the ground, but then shoots them up into the air.

It is anchored.
The problem is that when it re-configures the size and position of the bricks, it tries to put them on top of each other, resulting in the blocks moving up into the air.
How do I avoid this error?


while true do
m = Instance.new("Model")
m.Parent = game.Workspace
m.Name = "Tree"
t = Instance.new("Part")
t.BrickColor = BrickColor.new("Brown")
t.Anchored = true
t.Size = Vector3.new(2,1,2)
t.CFrame = CFrame.new(math.random(-800,800),0,math.random(-800,800))
t.Parent = m
l = Instance.new("Part")
l.BrickColor = BrickColor.new("Bright green")
l.Anchored = true
l.Parent = m
l.Size = Vector3.new(1,1,1)
for i = 1,10 do
t.Size = Vector3.new(2,i,2)
l.CFrame = t.CFrame + Vector3.new(0,(t.Size.y/3),0)
l.Size = Vector3.new(i,i,i)
wait()
end
wait()
end
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
04 Dec 2013 09:24 PM
Assign CFrame after Adjusting the size.
Report Abuse
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Dec 2013 09:26 PM
How?

It rndomly assigns the cframe.

How would I keep it in a fixed position without it jumping all over the place?
Report Abuse
secretidagent is not online. secretidagent
Joined: 07 Nov 2010
Total Posts: 1600
04 Dec 2013 09:28 PM
In the script make it change the size before assigning C-Frame.
Report Abuse
SimplyPure is not online. SimplyPure
Joined: 23 Jan 2011
Total Posts: 102
04 Dec 2013 09:30 PM
This probably doesn't make a difference but make the parent in lighting and at the end put it back in workspace. it will do a little flash I guess but I'mpretty sure most games have flashes c:
Report Abuse
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Dec 2013 09:31 PM
If I understand you correctly, you mean for me to put this line:

t.CFrame = CFrame.new(math.random(-800,800),0,math.random(-800,800))

After this:
for i = 1,10 do
OTHER THINGS
wait()
end

is that correct?

Because if it is then it will just grow from the origin and then move to a random position.
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
04 Dec 2013 09:34 PM
Just change it so every time you use:

i.Size = something

you have to do

i.CFrame = something

to reposition it correctly.

Otherwise it's using roblox's collision engine to see where to put is so it doesnt overlap anything.
Report Abuse
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Dec 2013 09:43 PM
Is there any way I can force it to overlap?
Like, if a tree spawns to close to another I dont want them to be on top of each other, I want them to be inside each other.
Report Abuse
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Dec 2013 09:47 PM
nvm
I got it guys.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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