There are parts of my game where we have to choose answers from the Player, and other cases where we have to choose answers from an NPC. The "conversation" menu position is "Above Player". Is there any way that the "conversation" menu is positioned on top of an NPC?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You can lock/unlock different Conversation menus that have different position types, but a Conversation itself has no built-in association with a character it might involve. You'd need to rely on scripting to dynamically position a menu over a specific character.
This script, for example, would reposition a menu named "MyConversationMenu" above any NPC it's attached to:
Sorry I can't get it to work. I have put the script in one of my NPCs and changed the menu name from "conversation" to "MyConversationMenu". The menu keeps popping up on top of the player all the time.
I don't know anything about programming. Perhaps this is beyond my capabilities as a developer. I understand that it is also outside of your responsibilities as a creator of AC but I think it is a functionality that could be useful for other users. I would greatly appreciate your help.
If someone else reads this and can help me out, that would be great.
In any case, right now my only alternative would be the first option that you propose. Manually position different conversation menus throughout the game. It would be a total of 5 or 6, it is a short game. It is not the best solution but it can work.
You don't need to rename the menu to match the script - you can rename the component Inspector's "Menu Name" field to match the menu. MyConversation is just the default value.
Let's see the properties of the Menu itself. Be sure to set its Appear type to Manual so that it can be repositioned.
Thanks I have tried it again. I changed the name correctly and it´doesnt work yet The NPC has a "speech menu placement child" that works fine por the subtittles so it´s working. But the conversation menu that I made for the npc doesn´t change the position to the npc. The Appear type is Manual. What "Position type" does he have to have? I tried "manual" and "above speaking character" but neither work.
Thanks so much for the help and sorry for my english...
Sorry, my mistake.
The Appear type should be left as During Conversation. It is indeed the Position type that needs to be set to Manual.
Also, the Menu needs to use Unity UI for it to be manually re-positionable.
The above script will position it over the NPC you attach it to. If it's not working, again - let's see the properties of the Menu, and also details of where/how you're using the script.
Are you looking to have this work with just one NPC, or multiple? A different approach will be needed if more than one - since the script above will reposition it for all NPCs that have the script attached at the same time.
Try the above, as you'll need to get it working anyway if you want to go with the multiple NPC method - and let me know after if you want help with getting multiple NPCs to work.
Ok, step by step. First of all I have created a new convention menu with Unity UI. The menu works and appears during the conversation, but I can't get it to position itself above the player. It always shows in the middle of the screen. I can't think of positioning it on an NPC if I can't even correctly position it on the player There is a capture with the menu design in case the error was there. The options buttons are made with a grid, as in the inventory tutorial.
Thanks for the support! You are the best!
AC sets a Unity UI-based Menu's position by manipulating the "RectTransform boundary" object that you assign in that Menu's properties.
That object should typically be an immediate child of the root Canvas, with all other objects set as children of that. For example, if you wanted the "Background" object to be your RectTransform bounadry, the Hierarchy should look more like:
-- Background
--- Titulo
--- Opciones
---- etc..
With "Background" then assigned as the RectTransform boundary in the Menu's properties.
The default interface's Conversation menu works in this way - see the /AdventureCreator/UI/ConversationUI prefab for a guided example.
As for the Player, you only mentioned NPCs until now - so the script above won't do anything when attached to the Player. This one will: