hey guys, im trying to spawn an object that continues to scale on one axis to match a distance between 2 points. now i know the calculation of the distance works fine as ive found out with debug. my issue is when the object spawns it does have the right value on the x axis, however as the distance gets larger the spawned object stays the same, what i want is the object to get larger every frame as the distance gets larger. also a 2nd issue is the object is pawning with values of 0 on both y and z axis, where i needed them on at least a scale of 1, i cant figure out why =S
here is the small bit of code (lines 194 to 203) which is my update section
A few things to start off with. You should use the code tags, they make it much easier to understand what we’re looking at. Why exactly do you need the arrow to get larger as it goes off into the distance?
The reason the arrow prefab is spawning at 0 is this line of code. It’s going to instantiate it at the position of the object the script is run on.
thankyou for your reply, its not the position it spawns that gets me, its the scale, i want it to essentially stretch out as i drag the mouse away from a ball, which is where the arrow spawns.
an example of what im trying to achieve can be seen here,
i want an arrow to spawn as i hold down the mouse and drag back, like on the video
There’s nothing wrong with your code for stretching the object, unless the distance isn’t getting greater. Perhaps try a small project with just the arrow and play around with it.
//maxArrowSize is the largest the arrow will grow.
//maxDragDistance is the distance at which the arrow will grow no more.
ArrowPrefab.transform.localScale = (maxArrowSize*(dragDistance/maxDragDistance));
I don’t do anything to stop dragDistance from getting larger than maxDragDistance here but that’s not to difficult to do.