Skip to main content
21 events
when toggle format what by license comment
Jan 1, 2016 at 2:33 history edited Adam P CC BY-SA 3.0
deleted 12 characters in body
Dec 31, 2015 at 23:58 vote accept Gutsee
Dec 31, 2015 at 23:58 comment added Gutsee Changing to offset.y = 0 worked. Thank you for the help and patience.
Dec 31, 2015 at 22:43 comment added Adam P Try setting offset.y =0 instead. That should work. If it does I'll change my answer.
Dec 31, 2015 at 19:54 comment added Gutsee It seems to only allow changes to all coordinates of the ray if they are together (x, y, z). I have tried changing only x and z in the code and it throws the same error. That Assets/Scripts/Player/PlayerShooting.cs(74,34): error CS1612: Cannot modify a value type return value of `UnityEngine.Ray.direction'. Consider storing the value in a temporary variable
Dec 31, 2015 at 19:34 comment added Gutsee I am getting an error on that line stating I should store it in a variable. I am not very familiar with var at this point. I have it like for (var i = 0; i < pellets; i++) {var offset = Random.insideUnitSphere * accuracy; shootRay.direction = transform.forward + offset; shootRay.direction.y = 0; I also tried shootRay.direction.y == 0 and shootRay.origin.y == 0. Edit: I cannot figure out how to format code in comment section.
Dec 31, 2015 at 14:14 history edited Adam P CC BY-SA 3.0
deleted 16 characters in body
Dec 31, 2015 at 14:14 comment added Adam P You are correct. I am changing it back.
Dec 31, 2015 at 14:04 comment added DMGregory @AdamP No, that's incorrect. Ray.direction, as the name implies, is a direction, or relative offset. It is not a second point on the ray. So a ray with a direction.y = 0 travels along an x-z plane passing through whatever point origin describes.
Dec 31, 2015 at 13:54 comment added Adam P @DMGregory that is assuming that shootRay.origin.y == 0. setting it to shootRay.origin.y ensures that it is at the same point in y.
Dec 31, 2015 at 13:49 comment added DMGregory @user3167069 Just set shotRay.direction.y = 0 before raycasting.
Dec 31, 2015 at 13:09 history edited Adam P CC BY-SA 3.0
added 16 characters in body
Dec 30, 2015 at 23:45 history edited Adam P CC BY-SA 3.0
edited body
S Dec 30, 2015 at 23:44 history suggested CommunityBot CC BY-SA 3.0
Edits to answer comment
Dec 30, 2015 at 23:43 review Suggested edits
S Dec 30, 2015 at 23:44
Dec 30, 2015 at 22:12 comment added Gutsee This code seems to be working except some of the shots are going above the enemies. I believe it is because the change in the y coordinates in Random.insideUnitSphere. The game is a TDS so there is no Y axis aiming. On a hunch I tried Random.insideUnitCircle, but realized that not only doesn't run, but that is x, y coords. Is there a way to change this? Thank you very much, you're a big help.
Dec 30, 2015 at 21:58 vote accept Gutsee
Dec 30, 2015 at 22:02
Dec 30, 2015 at 20:42 history edited Adam P CC BY-SA 3.0
deleted 2 characters in body
Dec 30, 2015 at 19:59 history edited Adam P CC BY-SA 3.0
added 115 characters in body
Dec 30, 2015 at 19:52 review First posts
Dec 30, 2015 at 20:01
Dec 30, 2015 at 19:50 history answered Adam P CC BY-SA 3.0