Each of the green squares is a spawn point for this script. The spawn point for the set of blue boxes is in the centre (0,1.5,0) of the scene. The other red boxes aren’t. Each of them are rotated at a 20 degree angle and the blue set is what I’m expecting. The others seem to change the distance from the green spawn point depending on where they are in the scene which is causing issues.
Can anybody suggest how to fix this issue so the rotation result is the same as the blue set regardless of the location of the spawn point in the scene? The script is below…
Your line 5 rotation is being applied to the Position you use in line 6 (where you multiply by the rotation) that you pass into Instantiate, so the position has been rotated at that point.
Instead, just position it with Position, THEN rotate it.
Personally I like to break each of these things into steps:
instantiate
position it
rotate it
All on separate lines of code to make the steps clear.
No, read carefully. You asked why your positions are wrong, and what I said is that YOU are rotating the position by taking rotation and applying it with multiplication in line 6.
If you NEED that rotation later, of course you keep it.
I’m saying your application of that rotation to the Position in line 6 is your actual problem making the positions incorrect.
Ah I see what you mean thanks! The use of the rotation earlier is causing problems because it’s rotating the initial spawn point. I’ve attempted to apply the rotation afterwards but it results in rotating the individual clones on their own axis rather than the direction the pile goes which is what I’m after and I’m unsure where to apply the rotation elsewhere as this seems to have the same result of rotating the individual cloned objects