Chickens and many other birds appear to bob their heads because their eyes are fixed in their sockets, so they can’t fix their eyes on a point while moving, but instead have to keep their head still. What looks like bobbing is the bird pushing its head forward and keeping it completely still for a moment while its body catches up. Without keeping its head still, it wouldn’t be able to see much of anything very effectively, prey or predator.
T rex might have been able to move its eyes, in which case it probably wouldn’t have bobbed its head.
It looks stupid but is insanely effective.
The bobs helps pick out movement, once they pick out prey, they have laser focus and stop bobbing.
If you don’t think they’re similar, watch a video of a chicken hunting a mouse. It could be a scene out of a very low budget Jurassic Park.
Edit:
Randomly came across a relevant video
https://www.youtube.com/watch?v=LfYV39SKIiM
Chickens and many other birds appear to bob their heads because their eyes are fixed in their sockets, so they can’t fix their eyes on a point while moving, but instead have to keep their head still. What looks like bobbing is the bird pushing its head forward and keeping it completely still for a moment while its body catches up. Without keeping its head still, it wouldn’t be able to see much of anything very effectively, prey or predator.
T rex might have been able to move its eyes, in which case it probably wouldn’t have bobbed its head.
The best is when you pick them up and move their bodies around but their little heads stay in the same spot
Nature’s own camera stabilizers.