Forum rules - please read before posting.

First person mode/New project questions

edited September 2014 in Technical Q&A
I'm trying out the first person movement method, and I have some questions about what is possible with the base Adventure Creator asset, and what needs some custom scripting.

Main Questions:
1) Turning without using the mouse. I have reviewed the available input axes, and I understand horizontal and vertical are for movement in those directions, not for turning. Further, I see the cursorhorizontal and cursorvertical axes, and the manual says to have them set to mouse movement. I'm not quite sure what they are used for. I have tried them out but I can't seem to figure out their purpose. Are they used to simulate horizontal and vertical mouse movement?

2) Simulating interactions. I understand for most adventure games the mouse is the main source of input for interactions, but I would like to create a keyboard shortcut as well. As I have it set now, when walking around in first person mode with the cursor locked to the center and the mouse used for moving the camera, there is no way to detect hotspots or "click" on hotspots to cause interactions. I have the playervicinity hotspot method on, but it still only detects hotspot when the cursor is unlocked, and therefore the player can no longer "look around". 

Is there any way to have my cake and eat it too? I want hotspots to be detected while the cursor is locked, and I want to be able to use a key (such as space bar) to "activate" hotspots, again, when the cursor is locked. 


Other Issues:
3)Jumping. Jumping using the default Adventure Creator input axis is very hit or miss. Sometimes it works perfectly, sometimes it doesn't work at all. Other times, if the player's side is against a collision cube, it works, and when the player is standing away from it, it does not. Has anyone else had this problem? I've been looking for the jump script with no luck, and I haven't really seen any description of the jump feature on the website or the manual. Any help would be appreciated.

4)Attacking. This game is an rpg adventure, and therefore combat is required. I want the player to be able to attack nearby enemies by both clicking on them with the context sensitive interaction method (which I believe is doable, and I'm sure I can figure it out) and also by clicking a key (1-9 for instance) or an onscreen attack button. The latter two methods are what I'm interested in. In a situation where an enemy is standing in front of the player, is there a way to detect the enemy's hotspot without using the mouse? I understand this question is similar to #2, but I'm also interested in figuring out how to cycle through targets (multiple enemies in melee range) and figuring out how to fire ranged attacks at far away enemies who are outside the player vicinity trigger object. I would imagine that I can send out a trigger object from the player's position, but I'm not sure how to figure out how to aim it at the enemy hotspot in the distance. Perhaps a "backup" ranged player vicinity trigger object, but then there is the problem of how to differentiate between the two. Is any of this doable with the base AC package?

5)Minimap. Perhaps this is more of a Unity question, but I would like to be able to create an onscreen minimap. I understand Unity Pro has a feature in which you can render a separate camera view into a texture, and perhaps display that in a 3D menu. However I would ideally like to use Unity free for the project, as this is just a hobby. Is there any straightforward way of making a menu element show a scrolling map of the area as well as a marker showing the player? This question might warrant it's own topic, or possibly a post on a more Unity specific forum, but I thought I'd ask to see if anyone has done something similar. 

6)Inventory and "magic" items. I want the game to have special items which use a single inventory item texture, but have different properties. Such as X armor of Y, having the properties of X and Y, versus A armor of B, which uses the same armor texture but has different properties. I understand how to randomize these features and I appreciate the very useful parameter tool which makes this much much easier, but I'm trying to conceptualize how exactly to give these items these properties. 

I believe that upon adding the item to the inventory, I can set certain variables which would then be checked upon examining the item. For instance, after adding "armor" I can set variable "prefix" to X, and variable "suffix" to Y, and then examining/using/equipping the item will check the variables and send the appropriate responses. However, I am unable to figure out how to "save" these variables for each particular item. If I pick up one "armor" and it has the properties X and Y, and then pick up another "armor" and want it to have different properties, and then have both of these armors in my inventory, the variables would change to the latest properties for each item. One possible solution I can think of is to GENERATE new variables for each item. This could get a bit messy, as I intend there to be many many items in the game, but it may work if the variables are deleted when the items are removed. But moreso, how would I even go about having the game generate variables for me? I presume scripting is involved, and maybe a basic idea of where to begin can help. Also, any other ideas for meeting this goal will be welcome.

As for the inventory, I would ideally like each item to be a different size, so that large items (like spears) take up more inventory slots in a grid than small ones (like rings). I'm thinking of a situation like in the Might and Magic and Diablo games, where "inventory tetris" is part of the game, and somehow pretty rewarding. Is this possible? Or would it be a huge mess? The only nonscripting solution I can think of is having multiple inventory items be used for larger items (such as 5 items make up a shield) but this is terribly messy solution, and I don't think it would be worth it.


That's all I have for now, I'm sure there will be more when I can think of them. Thanks as always for the help!

Comments

  • 1) For freeaiming with the mouse, yes: CursorHorizontal and CursorVertical must be set to mouse movement.  But if you want to map them to e.g. keyboard keys, or a Controller axis, then it'll still work.  You can use these axis to control free-aiming with something other than the mouse.

    2) There's nothing preventing Hotspots from only activating if the cursor is unlocked. Try using the default Demo player prefab, Tin Pot - set Movement method to First Person and Detect Hotspots to Player Vicinity. You can map the axis "InteractionA" to the keyboard, but this is only available when your Input method is set to Keybord Or Controller.

    3) If you want more robust jumping / FP movement in general, I suggest using the UFPS asset, which AC is compatible with.

    4) You'd almost certainly need to bolt on some custom scripting, since AC isn't built for combat.  However, when your Hotspot detection method is set to Player Vicinity, you can set Hotspots in vicinity to Cycle Multiple.  If more than one Hotspot is within the detection trigger, you can then use the CycleHotspotsLeft/Right buttons to select each one.  (This feature was originally intended to emulate Grim Fandango's control scheme, but should work here, too)

    5) Can't help with this, I'm afraid.  You shouldn't need to worry about integrating with AC's Menu system though.

    6) Would you not be able to use AC's Global Variable system to store these Variables?  As for "Inventory tetris", no - it's not possible. This may become more viable when Unity's new UI system is officially released, as I'll be integrating it with AC.  But again: bear in mind that AC is not specifically designed for combat / RPG games.

  • edited September 2014
    1) I tried mapping CursorHoizontal to the q and e keys, and it worked while the cursor was deactivated, however, when the cursor is again activated, it stops working. The view appears to be locked with the cursor is active. Is this supposed to be happening? Also, is there a way to use both movement options? In other words, can I map the primary button to the q and e keys, and the alternate to a mouse movement type? Or is this not possible with the way Unity input is set up?

    2) There may be a bug with this then. I tried with the Tin Pot prefab and it still only selects hotspots when the cursor is active. I have set the movement method to first person and hotspot detection method to player vicinity, and the hotspots do not highlight (nor interact) when the cursor is locked and deactivated, but once I press left alt to reactivate it, the hotspots will highlight. In fact it doesn't even matter if the cursor is over the hotspot, as the playervicinity method seems to be working, it just only works when the cursor is active.

    As to the second point- I tried your suggestion of using the keyboard or controller method, but for this project the mouse plays a fairly big role. Is there any way to change the AC script so that the InteractionA and InteractionB axes can be used in the mouse and keyboard input method? The input axes can be set to key or mouse button, so I presume Unity would allow me to set InteractionA to have a primary input of left click and a secondary input of space, if the option is available in AC.

    3) I don't believe I need much from the UFPS asset besides jumping, so I'm not sure it would be worth it for just that. I'm curious though how jumping is handled by AC. I am having a hard time finding any documentation about it. Although I am thinking about a different way of handling jumping. I noticed that since I last used AC, you have updated the menu properties to include a "actionlist to run when turn on" field. Could this be used to essentially add our own simulated input axes? If I were to set the menu to turn on when I press the x key, and set the actionlist to run when turn on to be an actionlist in which the player prefab moves 10 units in the y direction over .5 seconds, would this be a reasonable substitution? 

    4)This is definitely helpful. The problem now stems from the same problem I noted in #2, that these hotspots don't activate unless the cursor is active. I want to clarify one other question about this I had though:

    I want to set up an in game menu that has multiple buttons, each one with a different attack type, so that each button corresponds to a different type of attack, and runs a different actionlist. Once the enemy is in the player vicinity and the hotspot is active, is there any way to run this actionlist which performs the attack, but in doing so detects the currently active hotspot, and based on that particular hotspot, reduces the enemy "health" accordingly. What I'm essentially asking for is a "hotspot: check current" action, or something along those lines. Does that sound doable?

    5) Not important.

    6) My intention is to have randomized items. So the player opens a container, and anywhere from 2-6 items, each being of a random type (say, type 1-30), and then each type having 0-2 random properties A,B,C,D, etc., are added to the container. So in one container, the player might find Item 5 of X, and Item 17 of D. Besides creating a separate inventory item for each property (continuing with the lettering theme, that would be 26 items for each texture, 52 if each item can have two properties)  I would rather have one item for each texture, and then the ability to assign each item properties using variables. In doing this, I believe I would have to generate variables when I add the item to the container in order to keep track of the properties present on each individual item. 

    Am I missing something? Or is this all way too unclear? 

    I understand that AC is primarily for adventure games, and not meant for RPGs/combat, but I absolutely adore the ease of use and accessibility of the asset. Also I love RPG/Adventures and I want this project to have many adventure game elements which are tailor made for AC. That's why I'm trying to use this and not another program or extension.
  • edited September 2014
    Please try to limit these issues to one at a time, if you can - it's getting quite confusing to handle all of them at once.

    1/2) When the cursor is locked, it should remain in the centre - allowing you to free-aim.  When unlocked, free-aiming will not be possible, but the cursor can be moved around the screen.  Hotspots should be selectable in both modes.  What do you mean exactly by the mouse being "enabled"?  That's separate to it being unlocked.

    Unity is capable of mapping multiple keys to the same axis, if that's what you're getting at.

    3) You don't need to go through the Menu system to simulate input.  Just the Input: Check Action.  If the Action returns false, loop it back onto itself so that it runs again.  If the containing ActionList is set to Run In Background, it won't interrupt gameplay.

    4) A "Hotspot: Check current" Action wouldn't cut it, because you'd then have to create one for each and every enemy in your game.  Better to use parameters to pass this onto a "generic" ActionList asset that affects whatever GameObject you tell it to.  Assuming you've declared this asset as "actionListAsset", it's first parameter is set to be your active Hotspot, and said Hotspot has a ConstantID script on it, this code should assign it:

    actionListAsset.parameters[0].SetValue (GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInteraction>().GetActiveHotspot ().GetComponent <ConstantID>().constantID);

    You'd then have to run the asset manually, so as not to change the parameter to anything else:

    AdvGame.RunActionListAsset (actionListAsset);

    For more on parameters, see this tutorial.

    6) I understand what you want, but again this comes down to the adventure-focus of AC.  With this and the "inventory tetris", I really would advise looking for a more dedicated asset.
  • Okay, you've helped me figure out what my questions are, so I'll post some other topics about the other questions. 

    I'll keep this one about the first person view problems I've been having:

    The way I have it set up now in the settings manager is first person for movement method, mouse and keyboard for input method, and the "Hide cursor when locked" box is checked. So the problem I'm having is that when I play the game with these settings, and with the hotspot detection set to player vicinity, the hotspots are only detected when the cursor is NOT locked. So when I press the default "left alt" key to toggle the cursor off, so that it is locked to the center and hidden, as per the settings above, the hotspots are no longer detected, and I cannot interact with them.

    I was probably using the wrong words before, but this is the issue. I assume the hotspots should be detected in both cursor locked and cursor unlocked modes, as you've said previously, but this isn't happening in my game currently. 
  • edited September 2014
    So after a bit more testing, it seems the "Hide cursor when locked" setting is the culprit here. When it is not checked, the hotspots are active in both cursor locked and unlocked modes. So it looks like there is a bug at play when the "Hide cursor when locked" setting is checked.

    Ideally I would like the hotspots to function while the cursor is hidden, though I suppose that's not a priority at this point. 
  • Ah, now I see - thanks for explaining.  It's not a bug - just my way of thinking - i.e. if the cursor is hidden, how would the player know where on the screen Hotspots are going to be detected from?  If this is the wrong idea, it's simple to remove - though I don't know if others would agree or not.
  • I see, perhaps I can just alter it in my own project. I assume the appropriate script is:

    if (playerInput.IsCursorLocked () && settingsManager.hideLockedCursor)
    {
    DisableHotspot (true);
    return;
    }

    in the playerinteraction.cs file?

    I presume changing that from true to false will correct the issue? Thanks again for the help.
  • Close: you'll need to comment out the whole "if" statement.
  • Ah perfect, thanks.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!