-3

The target is to get gameobjects names and vectors, quaternions axis from an XML file and map axis to gameObjects names.

The exact problem is: mapping GameObjects to its axis and assigning a value to this axis to move mapped GameObjects according their axis. XML side: I can read every Name and MapTo attributes, but I don't know how to map the Name and MapTo attributes to each other in the way where I can assign the values to axis of mapped GameObjects.

<GameObject Name="Cube" MapTo="x"></GameObject>//x-y are vector axis
<GameObject Name="Cube" MapTo="y"></GameObject>
<GameObject Name="Cube" MapTo="z"></GameObject>
<GameObject Name="Cube" MapTo="a"></GameObject>//a-z are quaternion's axis 
<GameObject Name="Cube" MapTo="b"></GameObject>
<GameObject Name="Cube" MapTo="c"></GameObject>
<GameObject Name="Capsule" MapTo="a"></GameObject>
<GameObject Name="Capsule" MapTo="c"></GameObject>
<GameObject Name="Cylinder" MapTo="x"></GameObject>

I don't know what to try, but I want to have something to work with. Is there a way to accomplish this?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Hu Man
  • 71
  • 1
  • 1
  • 7
  • I'm looking for answer what to try – Hu Man Jan 09 '13 at 12:18
  • 1
    -1 First, you should try something before asking how to do it. Second, this question is really short and not clear. – Felix K. Jan 09 '13 at 12:19
  • I dont now what to try, but I want to have something to work with. second, I dont know what you want to know to help you with helping to me and to a person with the same problem. – Hu Man Jan 09 '13 at 12:27
  • I know there is no homework tag anymore but this seems exactly like a homework for me. But to be more clear what the problem ist: What is your exact problem? Do you have a problem with reading the xml file or what? – Felix K. Jan 09 '13 at 12:32
  • No, it is not a homework, it's the problem that I want to solve, and I need to come up with an idea how, I think it is useful to every one, how to analyze the problem and quickly start to solve it. So exact problem is: Mapping GameObjects to its axis and assign a values to those axis to move mapped GameObjects. XML side: I can read every Name and MapTo attributes, but I dont know how to map the Name and MapTo attributes to each other in the way where I can assign the values to axis of mapped GameObjects. – Hu Man Jan 09 '13 at 12:48
  • oh yeah now i now what it is a homework here in stackoverflow. Sorry – Hu Man Jan 09 '13 at 12:58

1 Answers1

0

I'm not sure if I fully understand the question, but if your goal is to move/rotate a set number of GameObjects you mapped according to the XML, I would recommend creating a script to treat the "MapTo" parameter to be realocated into variables for the axes, for example:

Vector3 objRotation;
Vector3 objMovement;

switch(MaptTo){
   case "x":
       objMovement.x = MaptTo
   break;
}

Hope it helps you solve your problem.

arosellisp
  • 31
  • 2
  • thank you for your answer, I came up with the same solution, but I cant assign the value to the right gameObject, when I'm trying to assign the value for specific MapTo of the Name, but the result is incorrect assigning for axis of incorrect gameObject, could you take a look through that? – Hu Man Jan 10 '13 at 08:28
  • How to map the Cube to the x,y,z,a,b,c and Capsule to a,x and Cylinder to x? – Hu Man Jan 10 '13 at 12:56
  • I guess you have to go throught the xml for each object individually, or create these movement/rotation references for each of the objects. The example I wrote would have to be inside a for() routine and would apply objMovement/objRotation whithin each loop. – arosellisp Jan 10 '13 at 13:33