Jump to content

Recommended Posts

Posted

Hi! im working on a project which need the user to pickup small objects on a table, like keys, cards etc. Is there a way to change the range of selection for it to be smaller? Cause even if the little hand is pointing at an object it might picked up another object thats closer or besides it.

 

 

(line: 450ish in FPSPlayer, and the the icon is 490ish)

local p0 = self.camera:GetPosition(true)

local p1 = Transform:Point(0,0,self.useDistance,self.camera,nil)

if self.entity.world:Pick(p0,p1, pickInfo, 1, true) then

 

tried changing the two zeros in the Transform:Point, but what it does is only moving the object selection range on the x,z axis and keeping the same range. so i can select the object when the middle of the window is more on the left or right.

 

and another question : at the end of a level before loading the new map i would like to fadeout to a DrawRec or Image. I know how to put it full on but is there a way to fade in/out?

 

Thanks guys!

Posted

The 4th argument of the pick can be set to 0. Which means a single raycast. From the docs:

radius: the radius of the ray. If the radius is greater than 0.0, a slower swept sphere collision will be performed.

 

As for the fade out, you can draw a black rectangle, and use a timer for its alpha.

  • Upvote 1
Posted

For the fading, here is a little example:

--In start
Script.alpha = 0
Script.fadeTime = 4

--In your game loop.
context:SetBlendMode(Blend.Alpha)
self.alpha =self.alpha + Time:GetSpeed()* 0.01
context:SetColor(0,0,0,Math:Lerp(0, 1, self.alpha/self.fadeTime))
context:DrawRect(0,0,400,400)
context:SetBlendMode(Blend.Solid)

  • Upvote 1
Posted

The pick is just a check between 2 points. The 4th argumen indicates the radius of the pick line. With 0 its a single raycast, while with a higher number you get a 'cylinder shape' cast. The 4th argument of the pick is not about distance from 1 point to the other.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...