Help with your scripting

physics.rayFromObject(Obj, target_Obj) [SOLVED]

physics.rayFromObject(Obj, target_Obj) [SOLVED]

Postby ant0N » 04 Apr 2015, 15:21

Hi! :D
Is it possible to have such a team in the future? And how can I do without her?

I just need to let ray from object A to object B.
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: physics.rayFromObject(Obj, target_Obj)

Postby SolarPortal » 04 Apr 2015, 15:48

There is currently no point to point raycast, but i think we should make it as it would be much easier.

Anyway, here is a working code that does work and does what you want.
i used the entity.getDirection(source target) to get the direction and then passed that through the rayFromPointByAxis() function.

Code: Select all
obj         = 0;
rayID         = 0;

function onInit(objID)
   obj = objID;
   rayID = physics.createRay();
   physics.rayDebugLines(rayID,1);
end

function onUpdate( td )
   x,y,z = entity.getPosition(obj)
   direction = newType.vec3(entity.getDirection(obj, entity.getIDFromTag("target")));
   hitID,pox,posy,posz = physics.rayFromPointByAxis(rayID, x,y,z, direction.x,direction.y,direction.z, 10);
   
   -- | Alternate method of getting direction. Not needed for this code though
   --targetPos = newType.vec3(entity.getPosition(entity.getIDFromTag("target")));
   --direction = newType.vec3(x-targetPos.x ,y-targetPos.y, z-targetPos.z);
end
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: physics.rayFromObject(Obj, target_Obj)

Postby ant0N » 04 Apr 2015, 15:54

thanks again! this is what I need. :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: physics.rayFromObject(Obj, target_Obj)

Postby ant0N » 05 Apr 2015, 06:16

SolarPortal wrote:
Code: Select all
obj         = 0;
rayID         = 0;

function onInit(objID)
   obj = objID;
   rayID = physics.createRay();
   physics.rayDebugLines(rayID,1);
end

function onUpdate( td )
   x,y,z = entity.getPosition(obj)
   direction = newType.vec3(entity.getDirection(obj, entity.getIDFromTag("target")));
   hitID,pox,posy,posz = physics.rayFromPointByAxis(rayID, x,y,z, direction.x,direction.y,direction.z, 10);
   
   -- | Alternate method of getting direction. Not needed for this code though
   --targetPos = newType.vec3(entity.getPosition(entity.getIDFromTag("target")));
   --direction = newType.vec3(x-targetPos.x ,y-targetPos.y, z-targetPos.z);
end


When using this method, the ray passes through obstacles.
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: physics.rayFromObject(Obj, target_Obj)

Postby SolarPortal » 05 Apr 2015, 09:16

that is because the crates are set on a flag of 2 for its collision data.
in the rayfrompointbyaxis() add the targetQuery varaiable like on the end of the rayfrompoint.

This way only the crates & character are going to pick up the raycast.
Have a look at the function (rayFromPoint() )that does work inside your code and copy of last argument into the other function.

Currently ray-casts can only target 1 collision query group at once. And that is set to "2" atm for your scene.

Hope this helps.
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: physics.rayFromObject(Obj, target_Obj)

Postby ant0N » 05 Apr 2015, 12:53

я все сделал, но ничего не изменилось..
Code: Select all
      local direction = newType.vec3(entity.getDirection(obj, target));
      local targetQuery = 2
      local hit,x,y,z   = physics.rayFromPointByAxis(self.ray2, self.x,self.y,self.z, direction.x,direction.y,direction.z, dist/20,targetQuery)
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: physics.rayFromObject(Obj, target_Obj)

Postby SolarPortal » 05 Apr 2015, 13:53

я все сделал, но ничего не изменилось..

I did, but nothing has changed ..


i shall take a look in the code now and see if it was implemented into this function.
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: physics.rayFromObject(Obj, target_Obj)

Postby ant0N » 05 Apr 2015, 13:57

SolarPortal wrote:
я все сделал, но ничего не изменилось..

I did, but nothing has changed ..


sorry, didn't notice... :)

I send you my project?
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: physics.rayFromObject(Obj, target_Obj)

Postby SolarPortal » 05 Apr 2015, 14:02

i have managed to replicate the fault on my machine and will set about it when i have a spare moment. I will try to get this in for the next release :)
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: physics.rayFromObject(Obj, target_Obj)

Postby ant0N » 05 Apr 2015, 14:03

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: physics.rayFromObject(Obj, target_Obj)

Postby SolarPortal » 10 Apr 2015, 16:06

i have found and fixed this problem for the next release :D
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: physics.rayFromObject(Obj, target_Obj)

Postby ant0N » 10 Apr 2015, 16:25

Excellent!! Soon I can move on... :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


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron