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 » Scripting Helpers
Home Search
 

Re: CFrame/TranslateBy help

Previous Thread :: Next Thread 
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
03 Jul 2014 06:22 PM
hey guys, im working on a RTS and its working fine, but I've noticed that when I click somewhere far away for the mini soldiers to move there, they go extremely fast, but when I click somewhere close to their original location, they go really slow... How would I fix this?

local pos = Vector3.new(mouse.Hit.p.X, 0, mouse.Hit.p.Z)
for i = 1, 100 do
wait()
if game.Workspace:findFirstChild(SOLDIER)~=nil then
game.Workspace:findFirstChild(SOLDIER):TranslateBy((pos-game.Workspace:findFirstChild(SOLDIER).Select.CFrame.p)/100)
end
Report Abuse
LegitimateBuisness is not online. LegitimateBuisness
Joined: 18 Feb 2014
Total Posts: 34
03 Jul 2014 06:32 PM
Because the (1, 100) can be different for each distance.
Report Abuse
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
03 Jul 2014 07:41 PM
Ok, so I've changed the to repeat until loop. But it still does the same thing.. How can I fix this? It also does the same thing with While loops aswell.

local pos = Vector3.new(mouse.Hit.p.X, 1 ,mouse.Hit.p.Z)
repeat
wait()
if game.Workspace:findFirstChild(SOLDIER)~=nil then

game.Workspace:findFirstChild(SOLDIER):TranslateBy((pos-SOLDIER).Select.CFrame.p)/100)
end

until (SOLDIER).Select.Position - pos).magnitude <= 5 or

(SOLDIER) ==nil)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 07:48 PM
(pos-SOLDIER).Select.CFrame.p)/100)

You are dividing by 100 still.

Divide by the initial distance.
Report Abuse
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
03 Jul 2014 07:57 PM
So divide by the magnitude between mouse click and soldier's position?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 08:03 PM
The initial soldiers position, unless you want something that gets exponentially faster.
Report Abuse
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
03 Jul 2014 08:06 PM
That works better, thanks.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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