-
Notifications
You must be signed in to change notification settings - Fork 0
/
angle_interptest.txt
61 lines (44 loc) · 1.26 KB
/
angle_interptest.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@name Angle InterpTest
@inputs Active Ent:entity Target:vector
@persist TurnSpeed [TarAng,EntAng]:angle [EndPitch,EndYaw] TarPos:vector MaxTurnSpeed
#This is the same way CAP makes its turrets turn to target things (but without the angle limits)
#its bad, use the angle_lerptest if you found this on my (Nova Astral) github
if(first()){
TurnSpeed = 0
EntAng = ang()
MaxTurnSpeed = 1
}
if(~Active){
if(Active == 1){
timer("update",1)
}
else{
TarPos = vec(0)
TurnSpeed = 0
stoptimer("update")
stoptimer("lerp")
}
}
if(clk("update")){
timer("update",100)
TarPos = Target
if(changed(TarPos)){
TarAng = (TarPos - Ent:pos()):toAngle()
EndPitch = angnorm(TarAng:pitch())
EndYaw = angnorm(TarAng:yaw())
timer("lerp",0)
}
}
if(clk("lerp")){
timer("lerp",10)
TurnSpeed = clamp(TurnSpeed+0.1,0,MaxTurnSpeed)
if(TurnSpeed == 1){
#stoptimer("lerp")
}
EntAng = EntAng:setPitch(mathApproachAngle(Ent:angles():pitch(),EndPitch,TurnSpeed))
EntAng = EntAng:setYaw(mathApproachAngle(Ent:angles():yaw(),EndYaw,TurnSpeed))
timer("setang",1)
}
if(clk("setang")){
Ent:setAng(EntAng)
}