Hey Guys, i get straight to the point I was asked if there is a possibility to have a tree that randomly spawns leaves on its branches by mouseclick. The idea behind it is for a fair that anyone can come by at the exhibition stand, click a button and then the tree spawns another leave somewhere randomly where theres space on it. So that at the end of the fair the tree is hopefully full of leaves. I’m still somewhat of a beginner, so i know how to do spawn points, but i can’t set thousands of spawn points by hand
Especially if it could be up to 40k leaves, and i don’t think that thats the best possibility there is
So if someone could help me out i would be very grateful
Thank you so much!! Have a great weekend
Especially if it could be up to 40k leaves
Depends on implementation it may work, but i doubt average approach will handle literally 40k leaves.
but i can’t set thousands of spawn points by hand
Assuming we are talking about 3d mesh of tree like this:
(random image from google)
Of the top of my head I can see a few approaches:
- Picking point:
1.1 Spawn a few dozens of sockets along the mesh manually; on spawn set position toNewTransform = SocketTranform +\- random offset along the branch
Probably the simplest and most sane implementation, easy to make, probably will look awful.
1.2 Throw a (semi-)random line traces until you hit a branch, spawn a leaf at hit transform.
Due to chances to hit a branch - each click can be computationally heavy, but there quite a few optimizations\simplifications possible. Should looks quite nice though
another leave somewhere randomly where theres space on it.
1.3 becomes quite simple if you can drop “anywhere randomly” condition and can spawn it in point you clicked. Then you can just trace mouse-to-world and this will give you some position on branch
1.4 something spline-based: draw a few(dozens?) of splines along the branches; Pick random spline from list; Pick random point on the spline; Draw at this point, perpendicularly to spline. Height of branch over spline can be found by trace from picked point to outside.
This one should have reasonable amount of manual setup and have quite a good looking result.
1.5 same as 1.4, but you have no preset mesh of tree and branches are also generate mesh at runtime along the same splines. Doubt you need it, but a possible extension of this approach
-
Drawing leaves:
2.1 meshes: static mesh actor\static mesh component on actor.
2.2 sprites. you can spawn new sprite at spawn point -
tricky sprites: each sprite will have a few(dozens) of leaves on it; sprites prespawned manually, content of the texture for each sprite is filled dynamically with new leaves at required\random points
Should look good, but may be quite tricky to implement.
Anyway, considering your task described not quite precise, at least it may give you a few ideas.
upd: revisiting listed ideas, i’d go for 1.4(spline based point picking) + 2.2 (sprites). Reasonably difficult in making, quite performant if you want to spawn a really large number of leaves
Thank you so so much for your detailed answer! I’ll try 1.4 and 2.2 as you suggested and see if its somewhat of they imagine their tree to be
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.