I have a simple animated sprite object which I am trying to move to several predetermined starting points, and then perform a simple series of moveTowards “animations” (think whack-a-mole but with just one mole that shows up around random points on the screen). But in addition to the position, I also need to adjust the scale of the object and the rotation. So what I would like to do, unless there’s a better way, is to create a multidimensional array of positions, scale, and rotation that I can loop through randomly. My background is PHP, so I’m a bit confused on how to create this array.
Here’s what I’m trying to do:
Array data (
Array (
scale = Vector3(x,y,z),
Array positions (
Vector3(x1,y1,z1),
Vector3(x2,y2,z2),
Vector3(x3,y3,z3),
Vector3(x4,y4,z4),
),
Array rotations (
Vector3(x,y,z)
)
),
Array (
scale = Vector3(x,y,z),
Array positions (
Vector3(x1,y1,z1),
Vector3(x2,y2,z2),
Vector3(x3,y3,z3),
Vector3(x4,y4,z4),
),
Array rotations (
Vector3(x1,y1,z1),
Vector3(x2,y2,z2),
Vector3(x3,y3,z3),
Vector3(x4,y4,z4)
)
)
)
The order of positions and rotations is important. The scale will only have one value, but the positions will always have 4, and the rotations could have one or 4. I’m striving for best-practice methods, so I appreciate any and all suggestions!
Thanks in advance.
Thank you for the help! So are you suggesting that it would be better to place empty gameObjects with Transform info that I want to animate my sprite to? The classes you suggest above make sense to me, however the "points" property isn't showing up when I attach the script to a gameObject...
– DondeEstaMiCuloWell, it should. Are you sure you have the System.Serializable attribute on both classes?
– Bunny83Yes, I literally copied and pasted. The only difference is I also included
– DondeEstaMiCulousing UnityEngine