Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 11:21 AM |
So I'm answering a help request, and I've worked something out that produces a remarkable accurate effect, for my first try, however, it has some hiccups. It gets pretty stuttery from time to time, and naturally the farther away you are from the target, the more unreliable it is as the target's speed changes.
What can I do to optimize the math? Making sure the indicator is as accurate as possible? It's difficult for me to explain what I did because I had a very hard time coming up with it in the first place.
Here's the place: https://www.roblox.com/games/574292732/Target-Anticipator
Here's the code: pastebin/WWuWgBWX
|
|
|
| Report Abuse |
|
|
RogueMage
|
  |
| Joined: 28 Jan 2012 |
| Total Posts: 1235 |
|
|
| 03 Feb 2017 11:22 AM |
Oh, just a little tip for your code
Use game.Workspace, not workspace
workspace is deprecated, I'm pretty sure. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 11:23 AM |
Can't really determine why it's so skippy.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 11:24 AM |
I don't believe it's deprecated I don't see why a function pointing to the workspace would be
|
|
|
| Report Abuse |
|
|
|
| 03 Feb 2017 11:37 AM |
| Capital Workspace was deprecated |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Feb 2017 11:44 AM |
use workspace not game.Workspace
game.Workspace is ugly
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 11:47 AM |
Yeah But what about the code itself?
|
|
|
| Report Abuse |
|
|
| |
|
Mr_Gibus
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 368 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 11:57 AM |
I posted the code, it's literally all there. The part is being moved by saying:
while wait() do part.CFrame = part.CFrame*CFrame.new(math.sin(tick()),0,0) end
|
|
|
| Report Abuse |
|
|
RogueMage
|
  |
| Joined: 28 Jan 2012 |
| Total Posts: 1235 |
|
|
| 03 Feb 2017 11:59 AM |
Ummmmmmm
I don't see anything wrong, it's probably because of ROBLOX's bad position detectors |
|
|
| Report Abuse |
|
|
Mr_Gibus
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 368 |
|
|
| 03 Feb 2017 12:00 PM |
| Why are you using Tick? is this object a clock? |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
| |
|
Mr_Gibus
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 368 |
|
|
| 03 Feb 2017 12:06 PM |
| I can't view the project due to not being at home. But perhaps use os.Time() insted? But this said the tick() value is just how long since January 1st, 1970 it is. So it should not stutter. Is the object the clock is connect to moving? |
|
|
| Report Abuse |
|
|
RogueMage
|
  |
| Joined: 28 Jan 2012 |
| Total Posts: 1235 |
|
|
| 03 Feb 2017 12:08 PM |
| If tick() is the problem here, maybe just use a variable that you're increasing 1 every time and math.sin() on it, that would be easy |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 12:09 PM |
Sorry Gibus I didn't think your question was genuine, so my reply was sarcastic. This is not in any way, shape, or form, a clock.
This is a system by which the future position of a part is detected based on its previous movement, and its worldly position is marked by a gui on your screen. It also takes into account the speed of your bullet, and shows you where you should put your bullet to hit the target
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 12:11 PM |
| No no no tick is not the problem XD It's used for determining the time since the last movement, and the number of potential movements that have occurred if that rate is constant, really just a variable for ######### but the possibleMotion is the kicker, whereby it determines how far the part could have moved, giving an indicator of the gui marker's potential inaccuracy. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 12:12 PM |
i-candy is censored but eye as in the sensory organs
|
|
|
| Report Abuse |
|
|
Mr_Gibus
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 368 |
|
|
| 03 Feb 2017 12:13 PM |
| so you mean "displaying" where an object will be given its current speed and rotation. I would CFrame a part or just use variables to the object's CFrame then change the value according to the objects speed. Then just use a world to screen point function to get the guis position. |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2017 12:14 PM |
| I tested it on my machine, it seems to work fine. |
|
|
| Report Abuse |
|
|
Mr_Gibus
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 368 |
|
|
| 03 Feb 2017 12:14 PM |
| You could also store the last few movements in a list then get the average position it might be at in a given time. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 03 Feb 2017 12:15 PM |
Gibus I think you should check the pastebin
@DoNotRead: Really? It's working fine for you, no skipping? That's interesting, what's your resolution?
|
|
|
| Report Abuse |
|
|
|
| 03 Feb 2017 12:16 PM |
| My screen resolution? 1920x1080, but I was in Studio mode. It was completely clean, no skipping. Perfectly smooth movement. |
|
|
| Report Abuse |
|
|
Mr_Gibus
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 368 |
|
|
| 03 Feb 2017 12:16 PM |
| I would suggest against moving any object with a loop it is insistent and unreliable. Just use body force, position, gyro, rocket. to move the part. Then getting its next position is a simple math problem given the objects current values... |
|
|
| Report Abuse |
|
|