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: Variable Soup -- Anticipating target motion

Previous Thread :: Next Thread 
Soybeen is not online. 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 is not online. 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 is not online. 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 is not online. 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
Ars_Technica is not online. Ars_Technica
Joined: 18 Jan 2017
Total Posts: 181
03 Feb 2017 11:37 AM
Capital Workspace was deprecated
Report Abuse
TimeTicks is not online. 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 is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
03 Feb 2017 11:47 AM
Yeah
But what about the code itself?


Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
03 Feb 2017 11:51 AM
Uncopylock it pleb
Report Abuse
Mr_Gibus is not online. Mr_Gibus
Joined: 17 Jun 2012
Total Posts: 368
03 Feb 2017 11:51 AM
One second let me see
Report Abuse
Soybeen is not online. 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 is not online. 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 is not online. 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 is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
03 Feb 2017 12:02 PM
Yes it's a clock.


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
03 Feb 2017 12:04 PM
Uncopylocked


Report Abuse
Mr_Gibus is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
DoNotReadThisNamePlz is not online. DoNotReadThisNamePlz
Joined: 01 Aug 2014
Total Posts: 679
03 Feb 2017 12:14 PM
I tested it on my machine, it seems to work fine.
Report Abuse
Mr_Gibus is not online. 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 is not online. 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
DoNotReadThisNamePlz is not online. DoNotReadThisNamePlz
Joined: 01 Aug 2014
Total Posts: 679
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 is not online. 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
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