|
Hello!
Here is my dilemma. I have been trying very hard to make a smooth working football that allows the user to click and hold to choose power of throw, and release to throw. Whilst this is happening, they can choose where they want to throw it by aiming the mouse. I was wondering if anyone had any ideas for what I need to do to achieve this goal, or if anyone would be willing to make one for me. I would be willing to pay quite generously, but of course, I would like to build it myself if possible.
Thank you in advance!
Respectfully,
bulldogslucky13 |
|
BlusephJoin Date: 2009-09-14 Post Count: 1273 |
A very nicely made mesh would probably achieve your goal of making a realistic football. For the scripting, it is possible if you know how to do so. |
|
|
@bluejays1236 Thanks for responding!
I have the mesh down, just not the scripting part, and that's what I'm talking about |
|
|
local speed = 100
local distance = 75
You will need this.
The code comes after this just to make scripting easier :) |
|
|
@killer4723 Thanks for the start! |
|
ScriptosJoin Date: 2008-06-17 Post Count: 2900 |
"I'd like to build it myself if possible."
Tips, then?
Use a LocalScript so that you can get the player's mouse.
( local mouse = game.Players.LocalPlayer:GetMouse(); )
Use the lookVector property of the position of the mouse to get the direction you want to throw to.
( local dir = mouse.Hit.lookVector; )
Multiply dir by the power you need to throw the ball.
( Can use mouse.Button1Down and mouse.Button1Up to get how long the player holds down the button to throw. This will get you the power needed to multiply by direction.)
You might want to add a maximum power so they can't throw the ball to the moon. |
|
|
@scriptos thanks for the help.
If I were to use mouse.Button1Down and mouse.Button1Up to get how long the player holds down the button to throw, what would I do to get the time in between the click down and up? How would I get the needed information, and store it, or use it? Like, how would I count how long it is being held?
Thanks! |
|
ScriptosJoin Date: 2008-06-17 Post Count: 2900 |
local mouse = game.Players.LocalPlayer:GetMouse();
local timeHeld = 0;
mouse.Button1Down:connect(function()
timeHeld = tick();
end);
mouse.Button1Up:connect(function()
timeHeld = tick()-timeHeld;
print(timeHeld);
end); |
|
|
@Scriptos right. Thank you! |
|
|
Any ideas for how to get the ball flying through the air, and falling with gravity? With time in the air dependent upon the power used to throw? |
|
TigeonJoin Date: 2013-05-24 Post Count: 4222 |
doesnt roblox already have gravity |
|
|
Yes. Thank you all for your help, and I have figured it out! |
|