Help with your scripting

To obtain the IDs of all objects in radius..?

To obtain the IDs of all objects in radius..?

Postby ant0N » 02 Apr 2015, 10:16

Don't know how to do it better. I need to know the IDs of all physical, located a short distance from the player ( I want to make an analogue vision for NPC)
Tried to do it through ray, but it can detect only one object.
Tried using a trigger, but it cannot detect stationary objects.

Any suggestions?
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: To obtain the IDs of all objects in radius..?

Postby SolarPortal » 02 Apr 2015, 10:49

You need to use the AI Sensor action added to the enemy AI:
Action editor > Player Category > AI Sensor


i have just tested and it picks up objects that are inactive.
It was tested it in the scene you sent me before (matrix3).

> Set the AI Sensor action to work on Flags 1 & 7. (Note: 7 is a number i chose as it could be any number over 5 as long as the character is matched.)
> Set the characters to 0 & 7.
> Set the Crate to 0 & 1. (1 allows the crate to be pushed around.)

This will stop the Sensor from reacting to the ground or normal physics entities and will only return characters or objects you specify the flags with, which increases performance and makes less to go wrong.

> Set the AI Sensor Range Property to something like 5.

Be careful as scaling the character seems to scale the AI Sensor debug sphere. So set entity Scale to 1,1,1. Change radius to match distance and then scale it down.

> If you need a faster detection, then decrease the "Think Speed" value for faster update.

> Add this code into a microscript (external will work next release hopefully).

Code: Select all
function onSensorContact_Enter(targetID)
   sky.lprint("SENSOR :: Detected Target: "..targetID);
end

function onSensorContact_Stay(targetID)
   sky.lprint("Target Staying: "..targetID);
end

function onSensorContact_Exit(targetID)
   sky.lprint("Target Exited: "..targetID);
end


I did notice that your characters were not 1:1 scale ratio and are currently at "0.081". You should use the mesh editor to rescale these and then set them to 1,1,1. It could be why your characters have issues following navmesh.

You also have to use a "Microscript" with the AI Sensor, as it does not callback to an external script yet.
I will check this out today as it is part of my current job now :)

Hint: Remove the trigger body and use the AI Sensor instead. It returns better and is based on a timer so will be quicker for characters and AI.

If you need any more help, let us know and we will respond :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: To obtain the IDs of all objects in radius..?

Postby ant0N » 02 Apr 2015, 11:07

Thank you SP! This is what I need. Could you send me your working example (matrix3)? :D
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: To obtain the IDs of all objects in radius..?

Postby SolarPortal » 02 Apr 2015, 11:58

yes sure :) Except i will have to set it up again in a downloaded version of skyline that matches yours.
As the Dev version has had improvement and upgrades made to both micrscript and External Scripts ;)
Something cool for the next release ;)

Will get back to you shortly.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: To obtain the IDs of all objects in radius..?

Postby ant0N » 02 Apr 2015, 12:08

If a new release is planned in the near future, I am willing to wait. :D :D :D
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: To obtain the IDs of all objects in radius..?

Postby SolarPortal » 02 Apr 2015, 12:13

Unsure on the release date yet, so i will still set your scene up and send you it which means you can still develop :)

The new features is something you asked for a long time ago and ideas brought forth by newer users for ease of use.
That's all i will say for now :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: To obtain the IDs of all objects in radius..?

Postby ant0N » 02 Apr 2015, 12:20

OK, thanks! :)
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: To obtain the IDs of all objects in radius..?

Postby SolarPortal » 03 Apr 2015, 20:54

i have pm'd you with the scene back :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: To obtain the IDs of all objects in radius..?

Postby SolarPortal » 17 Apr 2015, 17:50

I have some good news again.

  • AI Sensor action will now send the callbacks to external scripts.
  • AI Sensor "ALL" mode will return a table of IDs to the stay callback. e.g.

    Code: Select all
    function onSensorContact_Stay( idTable )


    Using the "ALL" mode allowed us to create a grenade and gravity well physics effect really easily.
    Here is an example for the next release:

    Gravity Well Effect:
    Code: Select all
    function onSensorContact_Stay( testTable )
       for k,v in ipairs( testTable ) do
          bodyID = physics.getBodyID(v);
          x,y,z = vector3.normalisedCopy(entity.getDirection(v,obj));
          strength = 300;
          physics.setForce(bodyID, x*strength,y*strength+30,z*strength );
       end
    end


    Grenade Effect:
    Code: Select all
    function onSensorContact_Stay( testTable )
       if(input.keyDown("space") == 1)then
          for k,v in ipairs( testTable ) do
             bodyID = physics.getBodyID(v);
             x,y,z = vector3.normalisedCopy(entity.getDirection(obj,v));
             strength = 30;
             physics.setImpulse(bodyID, x*strength,y*strength+30,z*strength );
          end
       end
    end


    The only change between the 2 effects is a flipped direction. One forces objects out, the other sucks them in.
    We have made some example scripts in the library for the next release with these examples.


I am currently working on multi-presets ;)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: To obtain the IDs of all objects in radius..?

Postby ant0N » 17 Apr 2015, 20:17

Cool! This will be very useful for me release... :D
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: To obtain the IDs of all objects in radius..?

Postby StevenP » 17 Apr 2015, 21:07

This is great! My planned games will rely heavily on AI.
User avatar
StevenP
Skyline Apprentice
 
Posts: 46
Joined: 07 Jun 2014, 21:19

Re: To obtain the IDs of all objects in radius..?

Postby SolarPortal » 18 Apr 2015, 12:09

@Steven: Your version of skyline already has the AI Sensor action, but it can only use the "Closest" shape option which returns the id closest to the center of the AI Sensor. With the next version of skyline though, some really cool scripts can be made reusable and editing without opening a script editor is great. :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 4 guests

cron