- Home /
texture terrain on click while scallling
Hello, i have a an issue with paiting the terrain at runtime, it essentailly works, but it runs in update. i need it to work after right click..
so what i am doing is creating a road section by clicking the ground with left mouse, and finishing the road by clicking right mouse button and i add a ground texture on the terrain under the road. but as i drag my road to make it longer, if i then decide i want the road shorter, and i back up, then right click terrain. the terrain will still have a longer ground texture, because it is running in update...and because im working with local to world conversion, its getting kind of tricky for me, and wondering if anyone can help.
here is some code to help understand: [CODE]
worldVec = surface.transform.parent.TransformPoint(surface.transform.localPosition );
var localVec = surface.transform.parent.InverseTransformPoint(startPos);
surface.transform.position = startPos + Distance / 2 * surface.transform.forward;
var dir = currPos - startPos;
Dir = snapTo(dir,90.0f);
var rot = Quaternion.LookRotation(Dir, Vector3.up);
if (distance2 >= 1f)
{
surface.transform.rotation = rot;//
surface.transform.localScale = new Vector3(surface.transform.lossyScale.x, surface.transform.lossyScale.y, Distance);
vecDent = new Vector3(worldVec.x + Dir.x/2, currPos.y, worldVec.z + Dir.z/2);
posList.Add(vecDent);
//Debug.Log(rot);
prevPos = currPos;
}
[/CODE]
so as you can see it adds positions to a list and then when i right mouse click to finish road it itterates through the list and then i apply the terrain texture
but since it is in update, if i move around my mouse and then move backwards then right click, it will draw the road to to long
i need to do this on right click, can anyone help please?
answer was in front of me the whole time, :( ....ughh its a struggle but getting somewhere...
Vector3 myVec = tempVec + i * surface.transform.forward; terrain.GetComponent().doHeights(myVec);
finally, click and drag roads coupled with navmesh surface, cheers!!
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
Change terrain texture colour 1 Answer
Flip over an object (smooth transition) 3 Answers