VGUI Movement

I’ve never really understood raw VGUI scripts. How do I go about making a VGUI that acts as your HUD, but making it so it’s a moving and/or rotating object? I’ve never really built a good VGUI from scratch, and the documentation in the wiki is sparse at best.

I basically want to get an icon in the corner of my screen move around like a little character that talks to you. I don’t want to resort to an animated material.

I basically need to know 2 things:
[li]How to change a VGUI image’s angles.
[/li][li]How to simulate movement by making an image jump/wiggle around on the screen.
I looked through the panel docs and couldn’t find anything documented relating to movement or rotations.

You can’t rotate panels. You’ll have to draw and rotate the texture yourself using surface.DrawTexturedRectRotated.

For the movement, there are a bunch of functions for that:

[li] Panel.MoveTo[/li][li] Panel.SizeTo[/li][/ul]

You can find all of them here.


These functions can be a bit glitchy if you don’t time them right. At least from my experience. I found that writing your own functions for the things you need work better.

Yeah. I want a little icon that jumps and wiggles around, and probably a little of both at the same time.

Will it be paperclip shaped?

Nope. :v:


Problem, MoveTo will always be a smooth path of motion. Is there any way I can get it to look like some form of physical motion? Like a bouncing ball?

Write a move function your self using SetPos?

Well that is obvious, I just don’t know how to go about simulating 2D physics.

To make it bounce smoothly use: offset + math.sin( CurTime() * frequency ) * amplitude
Then add some randomness to it with math.random to make it jitter a bit if you want.