PDA

View Full Version : Need Help with Third Person Action system


Sid
10-06-2005, 8:56 AM
OK, I need some help guys.. I am creating a Third person action game in WC3:tft and stuck upon a critical problem, I want to make these kind of controls...

Arrow Keys : Move in those directins... i.e. Hold "Up" to keep moving North, Hold "Down" to keep moving South, "Left" for West and "Right" for East.
Right Click : Fire in the direction i.e. If I Right Click a spot, My Unit should cast Shockwave on the spot where I Right Clicked!

Ok, now tell me How to accomplish it in the triggering... First of all I want all the people who want to reply here should try solving the problem out by actually working it out on WE, I don't want a "That should work" kind of reply. Note That I am also working this out, I spent 2 days for it but could not made it, so I am posting... Not justposting blind.. I EXPECT ANSWERS SOON...

edwinfong25
10-06-2005, 10:00 AM
OK, I need some help guys.. I am creating a Third person action game in WC3:tft and stuck upon a critical problem, I want to make these kind of controls...

Arrow Keys : Move in those directins... i.e. Hold "Up" to keep moving North, Hold "Down" to keep moving South, "Left" for West and "Right" for East.
Right Click : Fire in the direction i.e. If I Right Click a spot, My Unit should cast Shockwave on the spot where I Right Clicked!

Well, for the arrow keys the event is obviously Player - Keyboard Event. One way that I have seen it done and use myself is to create four variables. The variables should be "UnitPosition" (point), "UnitPositionX" (real), "UnitPositionY" (real), and "MoveDistance" (real). Then in the trigger you set the unit's current position to "UnitPosition". Then you set the "UnitPositionX" to the X value of the point indicated by "UnitPosition" and you set "UnitPositionY" to the Y value of the point indicated by "UnitPosition". (The variable "MoveDistance" is how far you want the unit to move and should be previously set.)

Next it depends on the direction you are going.
Lets use up for an example:

Event
Player - Player 1 (Red) presses the up arrow key
Condition
Action
Set "UnitPosition" = (position of unit)
Set "UnitPositionX" = (X of "UnitPosition")
Set "UnitPositionY" = (Y of "UnitPosition")
Set "UnitPositionY" = (UnitPositionY + MoveDistance)
Set "UnitPosition" = (point("UnitPositionX", "UnitPositionY")
Unit - Order "Unit" to Move To "UnitPosition"

This is not the only way to do it, but it works.
This would be good enough for moving the unit, but you would have to keep pressing the up arrow, instead of just holding it down.
Now, I know a few ways of doing this.
One good way is to set the actions in a different trigger (this trigger should have no keyboard event) with either a event of every % seconds, or to have it keep running itself by adding the Trigger - Run (this trigger). I recommend the trigger.(Also, if you use this make sure you have at least a Wait 0.01 action just before the Trigger - Run (this trigger). This trigger should be initially off. Next, make two triggers with Player - Keyboard Event. One should be for presses and one for releases. The press trigger should have the actions: Trigger - Turn on and then Trigger - Run. They should both refer to the trigger with the movement actions. Then with the release trigger, just turn off the trigger with the movement actions.

Then, for the right click.
First of all the right click is the smart command, so to make the right click do something, you would have to set it to the smart command.

Well, I hope the arrows help you and I will look into the right click and reply back.
Good Luck!

Basan
10-06-2005, 10:22 AM
Sid, I do recall that "Death Sheep" map (inside your WC3 maps folder by default installation) where your unit only could move to the left (aka West) n' to the right (aka East). ;)

Do ignore if EdwinFong's solution is any near that map's triggering, but you can peek at it as well to see if it solves your predicament. :confused:

edwinfong25
10-08-2005, 1:40 AM
Sid, I do recall that "Death Sheep" map (inside your WC3 maps folder by default installation) where your unit only could move to the left (aka West) n' to the right (aka East). ;)

Do ignore if EdwinFong's solution is any near that map's triggering, but you can peek at it as well to see if it solves your predicament. :confused:

Hey!
What's that supposed to mean?
Besides, that's where I originally got the idea from.
Then I added a little more so that it would be continuous.

Dayoh
10-08-2005, 1:46 AM
lol nvm him, that was a good trigger!
Look at the Death Sheep map u will learn heaps (thats were i learnt how to do some lol)
Maybe an email to Blizzard might be ok.

Sid
10-08-2005, 4:10 AM
Then, for the right click.
First of all the right click is the smart command, so to make the right click do something, you would have to set it to the smart command.

Well, I hope the arrows help you and I will look into the right click and reply back.
Good Luck!

Exactly, it solved the mess out, I finally edited the action for Keyboard events like this
Insead of
Unit : Order unit to Move to unit's position offset by xxx distance
I made it,
Unit : Order unit to Attack-Move unit's position offset by xxx distance

Then for the Right Click thing, I kept trigger like the way you said... Thanks man, that helped a lot !

hooded
10-08-2005, 10:14 AM
it may be easier to move the unit via the "point with polar offset", as it moves the unit in a forward or backward (positive or negative) distance based on an angle, which can be set to the direction the unit is facing.

this can also be applied to the camera, with a periodic event.

Zipsco
10-13-2005, 7:47 AM
Exsactly... I used the same as you are saying hooded(in a map i was trying a few weeks ago)... I also used the offset, as you are speaking of sid!, though i just found it better without knowing that anyone else did!... Also i found out that the only thing i didn't have control of was that freaking presses, and release thingy.... i made a trigger like this: (it is to say that iam trying to rotate the camera on left and right arrow keys, becouse i want a zoomed in locked on unit, type of fps)

turn left()(not jass dont worry)

player 1 presses left arrow

turn on move it left
______________________________
turn left nomore()

player 1 releases left arrow

turn off move it left
_________________________
and now:
move it left()

every 0.5 seconds of the game

set units rotation to units rotation + 1

__________________________________

Why isn't this working?

hooded
10-13-2005, 1:13 PM
if you want the camera to be all nice and locked with no periodic events:

event: player 1 presses left arrow key

condition: -

actions: set player 1's camera rotation to (facing of(red's first person unit))

i played around with this before, in the form of this map here, it has all the required triggers, but i havnt done much testing, so you may need to play with them:

Zipsco
10-13-2005, 4:54 PM
Thanks hooded, then i could actually just change the units facing angle before setting this.

Basan
10-17-2005, 10:00 AM
Hey!
What's that supposed to mean?
Besides, that's where I originally got the idea from.
Then I added a little more so that it would be continuous.

Oh boy... perhaps I should've explained it better up there. :P
"Do ignore mine if..." and the rest is history.

edwinfong25
10-18-2005, 5:25 PM
Oh boy... perhaps I should've explained it better up there. :P
"Do ignore mine if..." and the rest is history.

Yeah, it probably would be better if you explained better, but its alright. And that was still a good idea to look at the Death Sheep map.:cool:

Basan
10-19-2005, 7:41 AM
Yeah, it probably would be better if you explained better, but its alright. And that was still a good idea to look at the Death Sheep map.:cool:

*Meh* It wouldn't be a bad idea too, if ya somewhat alluded to the source on that 1st post of yours. But, what the heck now we've got it clearly didn't we? ;)

edwinfong25
11-05-2005, 12:12 PM
*Meh* It wouldn't be a bad idea too, if ya somewhat alluded to the source on that 1st post of yours. But, what the heck now we've got it clearly didn't we? ;)

Well, I only got the idea of moving the units around by means of the keyboard from the map and the way that I use is somewhat different than that of the map, considering that mine doesn't have to keep pressing the button to move.