HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Storing unit angle to a variable question

09-11-2002, 04:21 AM#1
Guest
I am trying to store a value of a unit's angle to a variable. The unit is created via a trigger. So here is what I have:

Events:
Time - Every 1 seconds of game time
Conditions:
Actions:
Unit Group - Pick every unit in (Units owned by player 1(red) of type <unit type>) and do (Set [variable]= (facing of (picked unit)))

I then ran an additional trigger that converted [Variable]to a string and periodically displays the value. Which SHOULD be the angle the unit is facing. However, it remains constant.

So what do you think?
09-11-2002, 07:16 AM#2
Guest
Why are you picking all units? Does player 1 have more than 1 unit? It's probably showing you the face value of a buildings or something.
09-11-2002, 11:46 AM#3
Guest
Because I was testing the (set [variable] = (facing (picked unit)))

There is only 1 unit owned by player one anyway. And it is created after map init. Heck, there was only 1 In my game at all. So there is no way picked unit should be anything else. With the way it is now, I could say pick all units on playable map area and get same results. :).

It just seemed like the "facing" wouldn't load into a real variable. Is there something literally wrong with that trigger? what kind of variable should it be. I read the FPS thread and I thought they said REAL. Which is what I have.

I did have:

Unit group - Pick every unit in (units in (playable map area) matching (((Unit-type of (matching unit)) Equal to [tank]) and ((Owner of (Matching unit)) Equal to Player 1 (Red)))) and do (set [variable] = (Facing of (Picked unit)))

I also tried:
Unit group - Pick every unit in (units in (playable map area) matching (((Unit-type of (matching unit)) Equal to [tank]) and ((Owner of (Matching unit)) Equal to Player 1 (Red)))) and do (set [variable] = (Facing of (matching unit)))

As I said there is only 1 unit controlled by a player at a time. (as of yet) It just seems like the variable I am trying to set doesn't change. It should change to something. My next task I guess is to make a trigger than shows the text of what the picked unit is. Just to make sure that part is working. Just curious of there was a bug in the facing trigger.

Thank you.
09-12-2002, 03:00 AM#4
Guest
Got a little further on this dilemma today.

Events:
Time - Every 1 seconds of game time
Conditions:
Actions:
Unit Group - Pick every unit in (Units owned by player 1(red) of type <unit type> ) and do (Set [variable]= (facing of (picked unit)))

Is what I was doing. Now I thought what if I try the same trigger but change it so it shows text of picked unit. like this:

Events:
Time - Every 1 seconds of game time
Conditions:
Actions:
Unit Group - Pick every unit in (Units owned by player 1(red) of type <unit type> ) and do (Game - display to (all players) for 3 seconds the text: (name of (picked unit)))

Now It did as I thought it would and showed the name of my created unit. So now I knew it was something to do with the action (set [variable] = (facing of (picked unit)))

Perhaps it won't work with units created after map initialization? So I create a basic unit (rifleman) and set it on the map. And then I make this trigger:

Events:
Time - Every 1 seconds of game time
Conditions:
Actions:
Unit Group - Pick every unit in (Units owned by player 1(red) of type rifleman ) and do (Set [variable]= (facing of (picked unit)))

VOILA! It works. So why isn't it working with my custom unit that gets created with a separate trigger at map initialization? I suppose my next test will be using a normal unit with the create unit trigger to see if it is the custom unit that does it or the created unit. (i think it is because it is created). If so then I would assume this is a bug. Has anyone else even tested with after reading these posts?
09-12-2002, 03:13 AM#5
Guest
Wow....all that trouble to find out it was my custom unit. see the tank i had was based on a hero and i had it's name and proper name different. I don't understand why yet, but when I chose the same name both both then the unit's angle would get calculated.

I can't believe that I figured that out. Only been modding a week and it really feels good to overcome a bug like that. Thanks to everyone that offered thoughts or opinions.

Hopefully this will add to the general knowledge here. If you are creating custom units and some stuff isn't adding up. Make sure the name and proper name of the custom is the same. :-D