I have made a really cool vehicle entry system for a game I want to release but if I get in the vehicle, move somewhere else and exit the vehicle, the variable of the vehicle does not update. So to get back into the vehicle I have to go back to where it spawns and enter it. Does anyone else have this problem? Anyone know a solution? Its hard to find any good information/tutorials on this in google or this site.
This is how it works.
- An event detects when the player's hero is within the range of 2 of the vehicle.
- Player has to press E to enter.
- Triggers hide the players hero and make him uncommandable.
- It gives control of the vehicle to the player.
- To exit the player clicks the 'Exit Vehicle' button while in the vehicle. (I made the button)
- It teleports the hero to the vehicle and makes him visible and commandable.
- It gives control of the vehicle back to neutral.
This works perfectly if you don't move the vehicle.
The problem is that, for some reason, in the variable for the vehicle, the position does't change when the vehicle moves.
I have tried making a separate variable just for the units position and updating it when the user exits the vehicle, but no luck.
I would really appreciate some help and thanks for your replies.
Here are some pics:
<u>Approach vehicle:</u>
<u>Text Tag Shows Instructions:</u>
<u>Enters Vehicle:</u>
<u>Click 'Exit Vehicle':</u>
<u>Leaves Vehicle:</u>
<u>Enter Vehicle Again:</u>
<u>Enters Vehicle:</u>
<u>Move Vehicle:</u>
<u>Click 'Exit Vehicle':</u>
<u>PROBLEM! Cannot press 'E' to enter.</u>
<u>Move back to vehicle spawn:</u>
<u>Text Tag shows on vehicle but user isn't near vehicle!</u>
<u>Enters vehicle way over there!</u>
Thats my problem...
Thanks for any help. =)
Well, first of all pics are nice - but without the trigger code it's hard to figure out the problem.
Are you using "Unit enters region" or "Unit enters point" to detect whether a player gets close?
The region or point does not update. So something like "Unit enters position of Quad" will not update if the unit moved.
If that's the case then switch it to "Unit enters range of unit" and praise my awesomeness.
If that isn't the case then you might want to post your map or script code (since it seems like relatively much script I'd prefer a map) and we can take a look at it.
I tried using "Unit Enters/Leaves Range Of Unit" but it does not allow me to use my unit variable.
The variable does not appear under the variable tab.
I need the vehicle to be a variable because I need to detect when the unit dies so I can re-spawn it.
QuadA1_E-within
Events
Unit - P1_Hero Enters a distance of 2.0 from 'Unit'
------- 'Unit' should be Quad_A1; Quad_A1 is my vehicle variable
Local Variables
Conditions
P1_QuadA1_E == false
Actions
Variable - Set P1_QuadA1_E = true
QuadA1_E-leaves
Events
Unit - P1_Hero leaves a distance of 2.0 from 'Unit'
------- 'Unit' should be Quad_A1; Quad_A1 is my vehicle variable
Local Variables
Conditions
P1_QuadA1_E == true
Actions
Variable - Set P1_QuadA1_E = false
QuadA1_Enter
Events
UI - Player 1 presses E key Down with shift Allow, control Allow, alt Allow
Local Variables
Conditions
And
Conditions
(Owner of Quad_A1) == 0
P1_QuadA1_E == true
Actions
Variable - Set P1_QuadA1_E = false
Unit - Hide P1_Hero
Unit - Change ownership of P1_Hero to player 0 and Retain Color
Unit - Make P1_Hero Uncommandable
Unit - Change ownership of Quad_A1 to player 1 and Change Color
Text Tag - Hide Quad1_Press_E-Tag for (All players)
QuadA1_Exit
Events
UI - Player Any Player presses Exit Vehicle
Local Variables
Conditions
(Owner of Quad_A1) == 1
Actions
Variable - Set P1_QuadA1_E = true
Unit - Change ownership of Quad_A1 to player 0 and Change Color
Unit - Change ownership of P1_Hero to player 1 and Retain Color
Unit - Move P1_Hero instantly to (Position of Quad_A1) (No Blend)
Unit - Show P1_Hero
Unit - Make P1_Hero Commandable
Variable - Set QuadA1_Pos = (Position of P1_Hero)
Text Tag - Show Quad1_Press_E-Tag for (All players)
Text Tag - Attach Quad1_Press_E-Tag to Quad_A1 with height offset 1.0
QuadA1_texttag-show
Events
Unit - P1_Hero Enters within 2.0 of (QuadA1_Pos offset by (0.0, 0.0))
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
And
Conditions
(Owner of Quad_A1) == 0
(Owner of (Triggering unit)) != 0
Then
Text Tag - Show Quad1_Press_E-Tag for (All players)
Else
QuadA1_texttag-hide
Events
Unit - P1_Hero Leaves within 2.0 of (QuadA1_Pos offset by (0.0, 0.0))
Local Variables
Conditions
Actions
Text Tag - Hide Quad1_Press_E-Tag for (All players)
Since you are using a region you need to make a trigger that moves the region to the unit. Although you would be better off not using a region and detecting when the player is near the vehicle.
If you are absolute on using regions then I would suggest not making a region for each and ever vehicle, make 1 circle region thats 2x2 or however big you want it and have it move to the player unit and instead of detecting when a player enters the region, have it detect when a vehicle enters the region.
I am way out of my league at this stage (im testing neutral bunker tonight, many thanks for the tips I got),
but could it be possible to give the vehicle an ability to load/unload a unit like a Hercules? (the Hercules even allows the unit to survive if destroyed which simulates a neet ejection system). It might be simpler to give the vehicle with such a load/unload ability the attribute that the unit it carries determines who controls the vehicle?
When I get a handle on the bunker, entering a vehicle to take it might come very soon on my list of things to test, I hope it can be done in a way thats more similar to the way I described above rather than having to deal with switching units and variables(too complex for me right now).
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Well, first of all pics are nice - but without the trigger code it's hard to figure out the problem.
Are you using "Unit enters region" or "Unit enters point" to detect whether a player gets close?
The region or point does not update. So something like "Unit enters position of Quad" will not update if the unit moved.
If that's the case then switch it to "Unit enters range of unit" and praise my awesomeness.
If that isn't the case then you might want to post your map or script code (since it seems like relatively much script I'd prefer a map) and we can take a look at it.
Heres all the code:
QuadA1_E-within
Events
Unit - P1_Hero Enters a distance of 2.0 from 'Unit'
------- 'Unit' should be Quad_A1; Quad_A1 is my vehicle variable
Local Variables
Conditions
P1_QuadA1_E == false
Actions
Variable - Set P1_QuadA1_E = true
---------------------------------------------------------------------------------------------
QuadA1_E-leaves
Events
Unit - P1_Hero leaves a distance of 2.0 from 'Unit'
------- 'Unit' should be Quad_A1; Quad_A1 is my vehicle variable
Local Variables
Conditions
P1_QuadA1_E == true
Actions
Variable - Set P1_QuadA1_E = false
---------------------------------------------------------------------------------------------
QuadA1_Enter
Events
UI - Player 1 presses E key Down with shift Allow, control Allow, alt Allow
Local Variables
Conditions
And
Conditions
(Owner of Quad_A1) == 0
P1_QuadA1_E == true
Actions
Variable - Set P1_QuadA1_E = false
Unit - Hide P1_Hero
Unit - Change ownership of P1_Hero to player 0 and Retain Color
Unit - Make P1_Hero Uncommandable
Unit - Change ownership of Quad_A1 to player 1 and Change Color
Text Tag - Hide Quad1_Press_E-Tag for (All players)
---------------------------------------------------------------------------------------------
QuadA1_Exit
Events
UI - Player Any Player presses Exit Vehicle
Local Variables
Conditions
(Owner of Quad_A1) == 1
Actions
Variable - Set P1_QuadA1_E = true
Unit - Change ownership of Quad_A1 to player 0 and Change Color
Unit - Change ownership of P1_Hero to player 1 and Retain Color
Unit - Move P1_Hero instantly to (Position of Quad_A1) (No Blend)
Unit - Show P1_Hero
Unit - Make P1_Hero Commandable
Variable - Set QuadA1_Pos = (Position of P1_Hero)
Text Tag - Show Quad1_Press_E-Tag for (All players)
Text Tag - Attach Quad1_Press_E-Tag to Quad_A1 with height offset 1.0
---------------------------------------------------------------------------------------------
QuadA1_texttag-show
Events
Unit - P1_Hero Enters within 2.0 of (QuadA1_Pos offset by (0.0, 0.0))
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
And
Conditions
(Owner of Quad_A1) == 0
(Owner of (Triggering unit)) != 0
Then
Text Tag - Show Quad1_Press_E-Tag for (All players)
Else
---------------------------------------------------------------------------------------------
QuadA1_texttag-hide
Events
Unit - P1_Hero Leaves within 2.0 of (QuadA1_Pos offset by (0.0, 0.0))
Local Variables
Conditions
Actions
Text Tag - Hide Quad1_Press_E-Tag for (All players)
Since you are using a region you need to make a trigger that moves the region to the unit. Although you would be better off not using a region and detecting when the player is near the vehicle.
If you are absolute on using regions then I would suggest not making a region for each and ever vehicle, make 1 circle region thats 2x2 or however big you want it and have it move to the player unit and instead of detecting when a player enters the region, have it detect when a vehicle enters the region.
I am way out of my league at this stage (im testing neutral bunker tonight, many thanks for the tips I got), but could it be possible to give the vehicle an ability to load/unload a unit like a Hercules? (the Hercules even allows the unit to survive if destroyed which simulates a neet ejection system). It might be simpler to give the vehicle with such a load/unload ability the attribute that the unit it carries determines who controls the vehicle?
When I get a handle on the bunker, entering a vehicle to take it might come very soon on my list of things to test, I hope it can be done in a way thats more similar to the way I described above rather than having to deal with switching units and variables(too complex for me right now).