1.
- set up a waypoint type to store the waypoint pivot entity. The plane should always point toward the current waypoint, and once reached, you should switch to the next waypoint until you reach your final target.
2.
An easy way would just involve a simple moveentity back and forth - the following example is intended to make a kick back and forth on the z-axis:
A more refined way is to move the gun using a sin() or cos() function in order to smooth the movement - that is, make the movement with a fast start and a slow end.
Sergio.
- set up a waypoint type to store the waypoint pivot entity. The plane should always point toward the current waypoint, and once reached, you should switch to the next waypoint until you reach your final target.
type t_wayp field pivot Global wayp.t_wayp for n = 1 to num_of_waypoints_to_create wayp.t_wayp = new t_wayp wayp\pivot = createpivot() ;or createcube for testing positionentity wayp\pivot,where_you_like_x,where_you_like_y,where_you_like_z next .. if entitydistance(my_plane,wayp) < minimum_distance then wayp\reached = true wayp.t_wayp = next t_wayp if not wayp then ;end of waypoint list reached endif else pointentity my_plane,wayp\pivot endif
2.
An easy way would just involve a simple moveentity back and forth - the following example is intended to make a kick back and forth on the z-axis:
global kick = false global kick_amount = 0 global kick_max_amount = 10 global kick_speed = 2 global delta = 10 ;limits the movement global z_memo# ;holds the previous gun's z position ; ; if shoot then kick = true kick_amount = kick_max_amount z_memo = entityz(my_gun) endif ; ; if kick then positionentity my_gun,x,y,z_memo - kick_amount/delta kick_amount = kick_amount - kick_speed if kick_amount <= 0 then kick = false endif endif
A more refined way is to move the gun using a sin() or cos() function in order to smooth the movement - that is, make the movement with a fast start and a slow end.
Sergio.