Forum rules - please read before posting.

find the position of an object

Is there a way to find the position (transform) of an Object, NPC, Player, with AC ?

Comments

  • You can use custom actions to find exact positions, but you can otherwise use Triggers.  Triggers can be used to detect the presence of a specific object - you can have a bool that is True when the object enters the Trigger, and False when it leaves.
  • not if the object (NPC or Player) is moving
    I know how to do this in script (find distance between two objects) and was using it in Unity scenes but I have tried to make an Actionlist that takes two GameObjects and returns the distance between them in a global variable. In this way I could have the typical NPC-detects-Player-depending-on-distance scene. I have followed your tut but the template does not have a return variable that can be used in AC. 

    I would be very willing to pay for such a thing, you see I am most interested in stealth scenes.
  • Have you read section 12.7 of the Manual?  Setting the value of a Global Variable (float) is very easy:

    AC.GlobalVariables.SetFloatValue (the_variable_id, the_new_value);
  • Yes, It could be easy but you must know that those scripts I mention I just copied from tutorials in Unity so I am still a neophyte in scripting . Please consider the following:

    Essentially I want to have an AC ActionList with these
    parameters:

    • ·       
      Object 1 (GameObject) (normally this would be
      the Player)
    • ·       
      Object 2 (GameObject) (normally this would be
      the NPC)
    • ·       
      Minimum distance to detect (float) (I choose it as a
      parameter)
    • ·       
      Returns a global variable float with the
      distance (for future possible actions such as shooting or exploding, etc.)


    Within this function if the distance < Min distance then
    Object1 follows Object2 as long as it is smaller

    If this is written as clearly as your example Template in
    the tutorial I would be willing to pay max 50 € for it. Do you know of anyone
    willing to do it?

  • It's not clear from your description what exactly you want the action to do - what you you mean by "Object1 follows Object2"?
  •  When using Unity alone, I used standard Unity-tutorial scripts such as:
    distance  = Vector3.Distance(player.transform .position, myTransform.position); 
    if (distance <= detectionRange) 
    .......
    where the NPC (object1)  follows the Player (Object2) as soon as the distance between the two is less than a predetermined value (externally defined). When this distance is greater then the NPC stops. I wanted also a returned bool variable that is set when the NPC has 'found' the Player (gotcha!) so I could use it to further create actions like explosions, etc.

    If I were to get such an ActionList I could use it as a Template for me rather than the insipid  Template about setting a Rigidbody (sorry) and I could do other stealth actions I have in mind.

     
  • Mind you, I have achieved the same thing with a Trigger as a child of the NPC which when the Player enters it it starts the NPC Follow Player action. Then I place Safe Areas (another trigger) around so that when the Player enters these areas it starts the NPC stop following Player action.

    So my request above is mainly for my own instructional purposes and of course seeing the guts of that action would give me a lot of intellectual wealth.
  • Why not give this book a try?


    I haven't read it myself, but I've seen people talking very highly about it recently, especially because it (apparently) explains the Unity scripting system in a very accessible way.

    AC builds on Unity, and obviously has to follow the rules as laid down in the game engine itself, so it definitely makes things a lot easier if you get a firm grasp of Unity before trying to get AC to do things it doesn't handle out of the box.



  • Snebjorn: I know there are books galore to learn C# and Unity but I am very, very old and have no energy nor willingness  to start learning a fresh new language (in my younger active life I was an active system programmer in C ) 
    I don't want to develop a 'game' but just scenes with different scopes just for kicks, I have done the same with Unreal, Valve, Unity, WinMaker and now I like AC.
    If I get to be able to change one or two functions (funny they call them now 'Methods") in AC to fit one or two 'situations' I'd be happy.
    If you think what I offer (50€) is too little to make any junior fellow interested then please let me know what would you suggest.
    .... and thanks a lot.
  • edited August 2015
    No problem - I just thought I'd mention this book because I've heard it focuses on the Unity scripting system without trying to teach the basics of programming at the same time.

    I've seen too many of those "Teach Yourself Professional Game Design, Systems Programming And Advanced Quantum Physics From Scratch In 30 Minutes Or Less" books.  :-)

    EDIT: Also: "Complete Idiot's Guide To Open Heart Surgery - A Hands On Approach"
  • edited August 2015
    But actually, there's some code in AC's NPC script that does something very close to what you're looking for: the StayAwayFromPlayer method. That's probably a good starting point - it would just be a matter of modifying the logic to detect the player and set him as the followTarget instead of moving away from him.

    I really don't think this should be handled through action lists - the StayAwayFromPlayer method is called from the NPC's _Update method.
  • Chris: I've read 12.7 and it couldn't  be less descriptive. 
    In my script I have a float that I want to be used in AC, I set AC_GlobalVariables.SetFloatValue(what is its 'int_id'??, float_value); 
    Then the manual says: "be sure to call Upload() function . where is this function? where do I use it?
    How do I identify in Variables Manager this global ? do I set 'Link to: " Data Option?
    Chris: Would it be a lot to ask i you could give me a sample of how to export a variable from script source to AC? 
  • edited August 2015
    See the scripting guide for more on this function - this is the recommended source for help with script functions.

    The "int _id" parameter refers to the Variable's ID number - which is shown just to the left of each variable's name in the Variables Manager: e.g. 1: Played intro has an ID of 1.

    The Upload function is a part of the Variable's class (see this page).  You can call it with the following:

    AC.GlobalVariables.GetVariable (2).Upload ();

    Where 2 is replaced by your variable's ID.

    So the following would set the variable with ID = 2, to a new value of 5.5, and affect it's "Linked to" source as well:

    AC.GlobalVariables.SetFloatValue (2, 5.5f);
    AC.GlobalVariables.GetVariable (2).Upload ();

  • THANKS. I made it work now my script detects the distance between the Player and the Enemy and shows in screen  but just once !!

    Object:My Enemy Attack
    Dialog:Play speech-> [var:6]

     I must be checking this distance constantly as I move the Player so that I can move the enemy towards the Player if less than a certain distance or stop him if not and this I can do with your standard ActionLists.

     wasn't this done with void Update() ? 
    Just a bit more, Chris, And I will be on my own 
  • I have done it now!!. With AC actions after I get the Global Variable from my script I do a  Variable:Check with 15 (my minimum distance) and if < I do a NPC Follow and if >  I do a NPC stop following Action and from either one it lops back into my new Action to check the real distance. Of course I have to run this cutscene in Background mode otherwise it just gets clobbered. 
    Thank you for the Variable 'tutorial' I can use this for many of the special actions I wanted such as Spawning objects, Get/SetPosition of an object.. these are things that were possible in PlayMaker which will work well with my mainly Stealth type scenes.
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.