3D Camera Shake

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By morningkingdom

Hi, as title say, i need the make camera shake after a signal emited, and i can do that. Shake the camera also is not too hard the make , there are few nice tutorials of it, but problem starts here;

root
-player
-camera
-camera_spatial

this is the hierarchy.

for smoot movment for camera, i did so that camera_spatial follow the player, and camera interpolited the camera_spatial,

camera script:

extends Camera
var velocity = 0.1


func _ready():
	set_process(true)
	make_current()

	player.connect("camera_shake",self,"_camera_shake")


func _process(delta):
	var camera_spatial = get_parent().get_node("camera_spatial").translation
	translation = translation.linear_interpolate(camera_spatial,velocity)



func _camera_shake():
		
	pass

camera_spatial script:

extends Spatial

var player
var distance_player : Vector3



func _ready():
	get_parent().print_tree()
	player = get_node("../player")
	distance_player = player.get_translation() - translation
	


	
func _process(delta):
	transform.origin = player.transform.origin - distance_player

while not destroy this setup, make a camera shake function for call it when signal emits, dont know how to do it.

output :

:bust_in_silhouette: Reply From: Andrea

i think thecamera.offset properties are the easier way to achieve the shaking effect, without touching the actual position of the camera in the world

Thanks, sometimes anwser too easy to found realy :D.

i did add an animation player, create new animation and key the H offset and V offset.
and call the animation when skill pressed.

thats it. Thanks.

https://streamable.com/byxoix

morningkingdom | 2021-03-21 14:25