x


Texturing per Script (controlling UV)

Hi Community, My character hase to shoot a rope. I thought about using a cylinder as rope because it will be taut (do you say it like that in english?) all the time. For the right length I would scale it on the local y-axis. But I want to be able to texture it. My question is how can I contoll the "procedural-texture-mapping" (how often the texture is set), so that my texture never looks scratched? i think I know that it is somewhere in materal section but I cant find it... (I hope my english isn´t too bad :D ) Thanks...

more ▼

asked Jul 09 '12 at 05:26 PM

AyJayKaySoft gravatar image

AyJayKaySoft
76 3 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Since you're shooting a rope, you have a start and an end point. Divide the length by the distance one rope texture "piece" should have and you get the scale factor.

Vector3 start = new Vector3(1, 2, 3); // just a random value
Vector3 end = new Vector3 (4, 5, 6);

float tileDistance = 2; // 2 world units per tile

void Update()
{
    float length = (start-end).magnitude;
    float numTiles = length/tileDistance;

    // scale the texture along the y axis
    rope.renderer.material.mainTextureScale = new Vector2 (1, numTiles);
}
more ▼

answered Jul 09 '12 at 06:05 PM

hathol gravatar image

hathol
1.6k 4 10

Yes, all I wanted to know was rope.renderer.material.mainTextureScale = new Vector2 (1, numTiles); but thank you :D

Jul 09 '12 at 06:53 PM AyJayKaySoft
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2197
x813
x237

asked: Jul 09 '12 at 05:26 PM

Seen: 338 times

Last Updated: Jul 09 '12 at 06:53 PM