Solved - aiming 8 directions

Started by idiotbox, Tue 28/06/2005 22:23:12

Previous topic - Next topic

idiotbox

I can get my player to aim his gun 4 directions depending where the mouse is and fire on mouse click. Even if I have 8 directional sprites, he will only face four of them. Is there a way to make him face diagonal too?

Babar

yes, use the diagonal sprites. I think you have to check "Use diagonal views" in the general menu
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

idiotbox

I don't see a use diagonal views anywhere. I have the diagonal ones placed in the view and it only seems to use them to turn the character left right up or down more smoothly. But it won't actually stop on these diagonal loops. Like, if the mouse is at the top of the screen, he will face up, if its at the right of the screen, he faces right and so on. But if I were to place the mouse at the top right corner, he should use his up-right loop, instead it either stays up or turns to the right. I hope this isn't confusing..

Ashen

It's on the 'Character' window (so obviously, you'll have to set it for each character you want to have 8 views). In 2.6 it's called No diagonal loops, in 2.7, it's just Diagonal loops.
I know what you're thinking ... Don't think that.

idiotbox

Oh, yes. That's already on. But all that does is make the character turn smoother cause it animates it, but it still doesn't actually stop on the diagonal loops when the mouse is in a diagonal position.

strazer

What's the code you use to have the character face the mouse position?

idiotbox

I use in repeatedly execute:
character[EGO].FaceLocation(mouse.x, mouse.y);

strazer

Doesn't work for me either (v2.71 Beta 2). Unless someone has any other ideas, I think this should be reported to CJ.

Ashen

You could probably force it to hold the diagonal loops with a bit of scripting - it depends on how exactly your game is set up (e.g. you could do it, but it'd look strange if the character was also walking).

But yes, it should definately be reported.
I know what you're thinking ... Don't think that.

idiotbox

Hm, well if my rooms did not scroll, then I could put hotspots in the corners, and change the view, loop or frame to a diagonal one when the mouse rolls over it.

Ashen

#10
Maybe you could use transparent, non-clickable GUIs placed in the corners of the room?

Or, if you're using 2.7+, you could use some fancy maths (such as the stuff [...] has in this post) to work out the angle of the mouse relative to character.x, character.y (or character.x - GetViewportX(), character.y - GetViewportY(), since you've got scrolling rooms), and set the loop accordingly. Been a while since I did that sort of maths though, so I couldn't tell you exactly what you'd need to do.
EDIT: And of course if you weren't too bothered about accuracy, you could probably fudge through it with some more basic maths.
I know what you're thinking ... Don't think that.

idiotbox

Hm, I realized changing loops when mouse goes over the hotspot is a bad idea because my character moves all over the room, it would only work if he stayed in the center. But I know you can face diagonal if you set the right coordinates, so maybe there's a way to just face these hotspots?

idiotbox

Ha, I made it work. Just took some mouse and character coordinates and assigned LockViewFrame to them. Thanks for the help anyway!

SMF spam blocked by CleanTalk