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 » Game Design
Home Search
 

Re: Why is this ray shooting torwards the Z axis

Previous Thread :: Next Thread 
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
17 Nov 2014 06:50 PM
local ray = Ray.new(lastVector.Position,lastVector.CFrame.lookVector*5)
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, {Workspace.Ignore})
local distance = (position - lastVector.Position).magnitude

local rayPart = Instance.new("Part",Workspace.Ignore)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.Blue()
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.FormFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position, lastVector.CFrame.p) * CFrame.new(0, 0, -distance/2)
rayPart.Transparency = 0.75
game:GetService("Debris"):AddItem(rayPart,0.025)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Nov 2014 06:52 PM
The "lookVector" is the relative -z axis of a CFrame (which returns a unit vector).
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
17 Nov 2014 07:02 PM
So how would I fix this?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Nov 2014 07:03 PM
Well is your problem that it's not shooting forward? It seems to be fine.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
17 Nov 2014 07:09 PM
Its not shooting forward based on the rotation of the starting point, its shooting torwards the Z Axis no matter what
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
17 Nov 2014 07:18 PM
Fixed it, had to rotate the vectors for the lookVector to work properly.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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