hi there!
is there a known way how to paint gameobjects on other gameobjects or growing some prefabs along a path or something like that?
thanx!
edit:
what i had in mind was a little tool to paint on the surface of an object and along this path there would be created the copies of an prefab in predefined distances or "densities"...
I will have some additional websearch to find some words to be more clear...
If I get your meaning, you want to instantiate one or more GameObjects along the surface of another GameObject, is that correct?
To do this, you would raycast and instantiate with the up vector being the normal of the surface that was hit, determining the rest of the new orientation some other way. Positioning is trickier because the object you are instantiating might have the pivot at the center (as opposed to the bottom), so you would have to calculate the offset to the bottom of the GameObject and instantiate at the hit.position + newOrientation * offset.
so with something like that i could start
function Update()
{
if (Input.GetButtonDown("Fire1"))
{
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast(ray, hit, 100))
{
var otherObj : GameObject = hit.collider.gameObject;
Debug.Log("Hit: " + otherObj.name);
if(otherObj.name == "nameOfObjectToPaintOn")
{
var newPos : Vector3 = new Vector3(hit.point.x, 0.8, hit.point.z );
var newObject : GameObject = Instantiate(thePaintPrefab, newPos, Quaternion.identity) as GameObject;
newObject.name = "newBulb_" + ++cnt;
allNewBulbs.Add(newObject); // to store the new positions
}
}
}
}