generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: For all you uber math people..

Previous Thread :: Next Thread 
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
05 Jan 2016 08:01 PM
This function works perfectly well, however, I can't seem to fix this issue: since I am using CFrame, the brick goes a few studs into another brick. How do I make it pop to the side? Also, if I position it right, it can go in a stud on top. I need to fix that also. I cannot use .Position because then it pops up and cannot be placed on the side of other blocks easily.




Mouse.Move:connect(function()
if CurrentBlock.Name ~= Current.Name then
CurrentBlock:Destroy()
CurrentBlock = Current:Clone()
CurrentBlock.Parent = workspace
Mouse.TargetFilter = CurrentBlock
end
local Position = Mouse.Hit.p
local Last = CurrentBlock.CFrame
CurrentBlock.CFrame = CFrame.new((math.floor(Position.X) + 0.5), ((math.floor(Position.Y) + 0.5) + (CurrentBlock.Size.Y / 2)), (math.floor(Position.Z) + 0.5))
if (Player:DistanceFromCharacter(CurrentBlock.Position) > 45) then
CurrentBlock.CFrame = Last
end
end)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Jan 2016 09:09 PM
Add on to it half the size of the parts? (of course if it's rotated, it'll be a little more complicated than that)
Report Abuse
MahouReikon is not online. MahouReikon
Joined: 15 Feb 2014
Total Posts: 1359
05 Jan 2016 09:46 PM
Stereotypes are not allowed
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
06 Jan 2016 02:52 PM
@cntkillme

The amount varies, and it's rotated :/
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
06 Jan 2016 03:01 PM
I'm ignoring your second issue for now; your first issue is quite interesting. You need to find out about how many stud units it is - no matter the rotation - to the next open space from a part. I solve this with a ray cast.

local R = Ray.new(RayBase.Position, RayBase.CFrame.lookVector * 100)
local PartHit, PositionHit, NormalHit = workspace:FindPartOnRay(R)
if (PartHit) then
print(PartHit.Name)
local ClosestRayPointToPartCenter = R.Unit:ClosestPoint(PartHit.Position)
local PenetrationDistance = (ClosestRayPointToPartCenter - PositionHit).magnitude * 2
print("Ray went through " .. PenetrationDistance .. " units of material " .. PartHit.Material.Name)
end

That will tell you about how many studs you need to push the block to make it come out the other side.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
06 Jan 2016 03:03 PM
How do I know which direction to move it?
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
06 Jan 2016 03:03 PM
R.Direction

Would be the direction to move it.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
06 Jan 2016 03:04 PM
What type is the direction? I am assuming a Vector3 like with fromAxisAngle?
Report Abuse
AlphaTitanium is not online. AlphaTitanium
Joined: 15 Jun 2015
Total Posts: 111
06 Jan 2016 03:05 PM
Send me some Scripts
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
06 Jan 2016 03:06 PM
Yeah, it's a direction. You'd just do:

Part.Position = PartHit.Position + R.Direction * (PenetrationDistance/2)
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
06 Jan 2016 03:06 PM
Wow, thanks. I am going to try this :D
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
06 Jan 2016 03:11 PM
Mouse.Move:connect(function()
if CurrentBlock.Name ~= Current.Name then
CurrentBlock:Destroy()
CurrentBlock = Current:Clone()
CurrentBlock.Parent = workspace
Mouse.TargetFilter = CurrentBlock
end
local Position = Mouse.Hit.p
local Last = CurrentBlock.CFrame
CurrentBlock.CFrame = CFrame.new((math.floor(Position.X) + 0.5), ((math.floor(Position.Y) + 0.5) + (CurrentBlock.Size.Y / 2)), (math.floor(Position.Z) + 0.5))
if (Player:DistanceFromCharacter(CurrentBlock.Position) > 45) then
CurrentBlock.CFrame = Last
end
local Ray = Ray.new(CurrentBlock.Position, (CurrentBlock.CFrame.lookVector * 100))
local PartHit, PositionHit = workspace:FindPartOnRay(Ray)
if PartHit then
local PenetrationDistance = ((Ray.Unit:ClosestPoint(PartHit.Position) - PositionHit).Magnitude * 2)
CurrentBlock.Position = ((PartHit.Position + Ray.Direction) * (PenetrationDistance / 2))
end
end)



It only works on one side and it just teleports really far away.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
06 Jan 2016 03:14 PM
"((PartHit.Position + Ray.Direction) * (PenetrationDistance / 2))"

Lol

(PartHit.Position) + (Ray.Direction * (PenetrationDistance / 2))
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
08 Jan 2016 02:59 PM
Nox, I have to say. You still failed me horribly :(

Mouse.Move:connect(function()
if CurrentBlock.Name ~= Current.Name then
CurrentBlock:Destroy()
CurrentBlock = Current:Clone()
CurrentBlock.Parent = workspace
Mouse.TargetFilter = CurrentBlock
end
local Position = Mouse.Hit.p
local Last = CurrentBlock.CFrame
CurrentBlock.CFrame = CFrame.new((math.floor(Position.X) + 0.5), ((math.floor(Position.Y) + 0.5) + (CurrentBlock.Size.Y / 2)), (math.floor(Position.Z) + 0.5))
if (Player:DistanceFromCharacter(CurrentBlock.Position) > 45) then
CurrentBlock.CFrame = Last
end
local Ray = Ray.new(CurrentBlock.Position, (CurrentBlock.CFrame.lookVector * 100))
local PartHit, PositionHit = workspace:FindPartOnRay(Ray)
if PartHit then
local PenetrationDistance = ((Ray.Unit:ClosestPoint(PartHit.Position) - PositionHit).Magnitude * 2)
CurrentBlock.Position = ((PartHit.Position) + (Ray.Direction * (PenetrationDistance / 2)))
end
end)






Only works on 1 axis and it still pops far away to the side -_-
Report Abuse
rowerowe71 is not online. rowerowe71
Joined: 14 Apr 2013
Total Posts: 1999
08 Jan 2016 03:00 PM
you could get the surface type and use that

i did something similar and that worked fine for me
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
08 Jan 2016 03:01 PM
I'm not going to bother looking at your code. I worked on that algorithm for someone on the dev forum. I know it works because I personally tested it. If you can't apply it correctly, what do I care?

"You still failed me horribly :("

It's not my job to integrate it with you code.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
08 Jan 2016 03:03 PM
You tell me if this works; it clearly doesn't. I implemented it perfectly, as far as I can tell.


local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local Bricks = game.ReplicatedStorage.Bricks:GetChildren()

local Number = 1
local Current = Bricks[1]

game:GetService("UserInputService").InputBegan:connect(function(InputObject, GameProcessedEvent)
if not GameProcessedEvent then
if InputObject.UserInputType == Enum.UserInputType.Keyboard then
if InputObject.KeyCode == Enum.KeyCode.E then
Number = (Number + 1)
if (Number == (#Bricks + 1)) then
Number = 1
end
Current = Bricks[Number]
end
end
end
end)

local CurrentBlock = Current:Clone()
CurrentBlock.Parent = workspace

Mouse.TargetFilter = CurrentBlock

Mouse.Move:connect(function()
if CurrentBlock.Name ~= Current.Name then
CurrentBlock:Destroy()
CurrentBlock = Current:Clone()
CurrentBlock.Parent = workspace
Mouse.TargetFilter = CurrentBlock
end
local Position = Mouse.Hit.p
local Last = CurrentBlock.CFrame
CurrentBlock.CFrame = CFrame.new((math.floor(Position.X) + 0.5), ((math.floor(Position.Y) + 0.5) + (CurrentBlock.Size.Y / 2)), (math.floor(Position.Z) + 0.5))
if (Player:DistanceFromCharacter(CurrentBlock.Position) > 45) then
CurrentBlock.CFrame = Last
end
local Ray = Ray.new(CurrentBlock.Position, (CurrentBlock.CFrame.lookVector * 100))
local PartHit, PositionHit = workspace:FindPartOnRay(Ray)
if PartHit then
local PenetrationDistance = ((Ray.Unit:ClosestPoint(PartHit.Position) - PositionHit).Magnitude * 2)
CurrentBlock.Position = ((PartHit.Position) + (Ray.Direction * (PenetrationDistance / 2)))
end
end)

Mouse.Button1Down:connect(function()
CurrentBlock.Transparency = 0
CurrentBlock = Current:Clone()
CurrentBlock.Parent = workspace
Mouse.TargetFilter = CurrentBlock
end)
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
08 Jan 2016 03:07 PM
As I said, I'm not going through your code. I'm not that good to learn people's code that fast, sorry. Here's some proof of my tests:

prntscr(dot)com/9np101
prntscr(dot)com/9np165
prntscr(dot)com/9np1cg

That last one is actually demonstrating how accurate it is. That gray block is the length that the penetration distance returns.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
08 Jan 2016 03:10 PM
It doesn't work. I did exactly as you told.

I will wait for someone else..
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
08 Jan 2016 03:11 PM
Good luck. It works fine, as I just showed you.
Report Abuse
XhappysmileX is not online. XhappysmileX
Joined: 22 Feb 2009
Total Posts: 124
08 Jan 2016 03:12 PM
I'm testing nox7's method and it works fine. I think it's funny you think he'd insist his method so much and you think it's wrong. He's one of this forum's biggest math prodigies.
Report Abuse
IFrozenJustice is not online. IFrozenJustice
Joined: 26 Dec 2015
Total Posts: 49
08 Jan 2016 03:12 PM
you could try using body positions. and make the code way simpler.


thanks babe
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
08 Jan 2016 03:23 PM
Here, I made a testing place you can check out. Uncopylocked.

http://www.roblox.com/games/341065776/Bullet-Penetration-Thickness-Calculation
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
08 Jan 2016 03:31 PM
@IFrozen
No, then it isn't immediate.

@XSmile

I think it's funny how your a noob; it isn't working for me. Now get out, your new here.

@Nox

I see what your saying; I can't seem to replicate it :(




Oh well, I give up.
Report Abuse
IFrozenJustice is not online. IFrozenJustice
Joined: 26 Dec 2015
Total Posts: 49
09 Jan 2016 12:22 PM
you can cheat by making the speed fast enough so that it basicly looks like it teleported, tricks i use a lot


thanks babe
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image