|
| 04 Jul 2012 02:11 AM |
I am making a _theoretical_ aimbot for daxter33's Paintball game. I may use it a few times when I'm finished :]
local g_a=Vector3.new(0,-98.1,0)--global_acceleration (gravity)
local t_p=Vector3.new(4,9,6) --target_position local t_v=Vector3.new(-5,3,2) --target_velocity
local b_p=Vector3.new(50,76,-30) --bot_position local b_m=100 --bullet velocity magnitude
Those are my global variables that will be used to calculate the variable 'b_d' which stands for bullet_direction, and must be a Unit Vector. Using the equation for motion and a time variable, the positions of the bullet and the target must be equal at some point in time:
t is unknown and stands for time, and b_d is unknown.
b_p + t*b_m*b_d + t^2*g_a = t_p + t*t_v + t^2*g_a
I solved for bullet_direction:
--gravity cancels out on either side :D b_p + t*b_m*b_d = t_p + t*t_v
--move b_p and flip equation <-> t_p - b_p + t*t_v = t*b_m*b_d
--divide by t*b_m (t_p - b_p + t*t_v)/(t*b_m) = b_d
now, all that needs to be done is find the value of t where b_d is a unit vector (.magnitude==1). I made a guess and refine to 14 decimal places for loop, but since there's only two, one, or zero answers, shouldn't there be an exact method?
t=0.9007656213628 is the correct answer, but I found that using guess and check. (there is a negative answer, but that doesn't make sense for this situation)
Also, what if the target isn't jumping? Then gravity doesn't cancel out because it doesn't apply to the target. The equation is then:
(t_p - b_p + t*t_v - t^2*g_a)/(t*b_m) = b_d,
but the requirements are the same: b_d must have a magnitude of 1.
these functions describe the position of the bullet and the target for a given t:
--target equation while falling local function t_pos_fall(t)--t=time return t_p + t*t_v + t^2*g_a end --target equation while walking local function t_pos_walk(t)--t=time return t_p + t*t_v end
--bullet equation (b_d must be defined) local function b_pos(t) return b_p + t*b_m*b_d + t^2*g_a end
This script creates a visual:
local tar=workspace.Target local bul=workspace.Bullet tar.CFrame=CFrame.new(t_p) bul.CFrame=CFrame.new(b_p) for i=0,T,1/30 do --T is the time of impact, a.k.a when b_d.magnitude==1 tar.CFrame=CFrame.new(t_pos_fall(i)) bul.CFrame=CFrame.new(b_pos(i)) wait() end tar.CFrame=CFrame.new(t_pos_fall(T)) bul.CFrame=CFrame.new(b_pos(T))
|
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 02:21 AM |
Main point: How 2 find bullet_direction without guess and refine? |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 05:12 AM |
| Just hax daxters source, and check math he used and maik st00pid aimb0t. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 05:33 AM |
| Oh, that's another thing, I need the actual velocity and gravity he used :P |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 05:35 AM |
| No, he didin't use velocity, just CFrame with some math. Velocity would spazz like his grenade in that game, but bullets doesnt. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 05:38 AM |
| Yes, each bullet would have a speed it leaves the gun at. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
| |
|
|
| 04 Jul 2012 05:41 AM |
| -_- not roblox, the CFrame changes by the velocity each time. The velocity changes by gravity (acceleration) each time. Take Physics. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 05:44 AM |
| ...The bullet is ANCHORED, and is moved using COORDINATE FRAME! If he would use velocity only, bullets would spazz out like grenades and would work like thouse old guns what shoots random ballz. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 05:49 AM |
| You are misunderstanding what I am saying. I am not saying that "I think he uses part.Velocity=blahblah vector speed" NO I am saying there is required unseen physics that I know exist because of un-glitchyness. I 100% agree with what you are saying, but you are misunderstanding me when I say velocity. when I say velocity, I mean the rate of change of the Position, which is obviously set by a CFrame. There is another factor which affects the UNSEEN velocity; acceleration. This acceleration is most likely -98.1 studs/s^2, but he may have used something different. the initial velocity is most likely around ~500 studs/s, but he may have used something else. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 05:51 AM |
"Just hax daxters source, and check math he used and maik st00pid aimb0t."
Also you might want to try:
for num=0,1,0.1 do point = point:Lerp(point2,num) end |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 05:58 AM |
That is not a parabolic trajectory :P
local p=Vector3.new(-22,16,14)--initial position local v=Vector3.new(10,50,-25)--initial velocity local a=Vector3.new(0,-98.1,0)--acceleration due to gravity
local function pos(t) --t for time return p+v*t+a*t^2 end for t=0,2,0.1 do ball.CFrame=CFrame.new(pos(t)) end |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 06:03 AM |
There, leaked source for you:
while true do local bulletFront = (bullet.CFrame * CFrame.new(0, 0, -1)).p - Vector3.new(0, bulletDrop, 0) local dir = (bulletFront - bullet.CFrame.p).unit local position = prevPosition + (dir * length) local hit, endPos = _G.castRay(bullet.CFrame.p, bulletFront, ignore) local newDistance = (endPos - prevPosition).magnitude collidePos = endPos collide = hit if (newDistance < length) then break end local bulletDistance = (position - prevPosition).magnitude bullet.Size = Vector3.new(0.05, 0.05, 5) bullet.CFrame = CFrame.new(prevPosition, position) * CFrame.new(0, 0, -bulletDistance / 2) prevPosition = position wait() end bullet:Remove() |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 06:10 AM |
| I think I need more of the code to get the info I'm after. At first glance, this doesn't even look parabolic... but looks may be deceiving. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 06:11 AM |
function projectile(weapon, start, target, damage, speed, drop, color, ignore) local collide = nil local collidePos = nil local ratio = 10 local dir = (target - start).unit local hit, endPos = _G.castRay(start, target, ignore) local distance = (endPos - start).magnitude local bulletDrop = (drop / ratio) / 250 local length = speed / ratio local prevPosition = start local bullet = Instance.new("Part", ignore) bullet.Name = "PartGranade" bullet.BrickColor = color bullet.formFactor = "Custom" bullet.Anchored = true bullet.CanCollide = false bullet.CFrame = CFrame.new(start, endPos) game.Debris:AddItem(bullet, 5) if (distance > length) then while true do local bulletFront = (bullet.CFrame * CFrame.new(0, 0, -1)).p - Vector3.new(0, bulletDrop, 0) local dir = (bulletFront - bullet.CFrame.p).unit local position = prevPosition + (dir * length) local hit, endPos = _G.castRay(bullet.CFrame.p, bulletFront, ignore) local newDistance = (endPos - prevPosition).magnitude collidePos = endPos collide = hit if (newDistance < length) then break end local bulletDistance = (position - prevPosition).magnitude bullet.Size = Vector3.new(0.05, 0.05, 5) bullet.CFrame = CFrame.new(prevPosition, position) * CFrame.new(0, 0, -bulletDistance / 2) prevPosition = position wait() end bullet:Remove() else local position = prevPosition + (dir * length) local hit, endPos = _G.castRay(start, position, ignore) local distance = (endPos - start).magnitude local newDistance = (position - start).magnitude bullet.Size = Vector3.new(0.1, 0.1, distance) bullet.CFrame = CFrame.new(start, endPos) * CFrame.new(0, 0, -distance / 2) game.Debris:AddItem(bullet, 0.1) collidePos = endPos collide = hit end checkDamage(collide, collidePos, color, damage, weapon) return collidePos end |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 06:17 AM |
| huh, I would have done it with alot more physics :/ |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
| |
|
|
| 04 Jul 2012 06:20 AM |
@MonkeyMan There is no point, you can't actually put this script on his place. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 06:20 AM |
| is it even parabolic? it certainly doesn't appear to be... |
|
|
| Report Abuse |
|
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 06:22 AM |
| @apda. Yes it is, if you're doing same way i got source. Thought that's very simple, and blah. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 06:24 AM |
| I'd still like to solve the problem though :] |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 04 Jul 2012 06:25 AM |
| Well you don't need trajectory, just make so it aims distance*X or somthing, so it always gts a hit. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2012 06:29 AM |
| that's why I need trajectory... |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 04 Jul 2012 06:52 AM |
Like angle trajectory?
local angleNeeded = .5*math.asin(((p.CFrame.p - hitpoint.p).magnitude)*196.2/200^2) |
|
|
| Report Abuse |
|
|