Consistency/data/entities/animals/boss_ghost/polyp_trajectory.lua

18 lines
604 B
Lua
Raw Normal View History

2021-08-20 01:53:47 +00:00
dofile_once( "data/scripts/lib/utilities.lua" )
local entity_id = GetUpdatedEntityID()
local pos_x, pos_y = EntityGetTransform( entity_id )
SetRandomSeed( GameGetFrameNum(), pos_x + pos_y + entity_id )
edit_component( entity_id, "VelocityComponent", function(comp,vars)
local vel_x,vel_y = ComponentGetValueVector2( comp, "mVelocity")
local scale = math.max( math.abs( vel_x ), math.abs( vel_y ) ) * 0.4
local random_adjustment = Random( 0 - scale, scale )
vel_x = vel_x + random_adjustment
vel_y = vel_y + random_adjustment
ComponentSetValueVector2( comp, "mVelocity", vel_x, vel_y)
end)