ChangeView not working

Started by nightmarer, Tue 10/01/2023 23:44:03

Previous topic - Next topic

nightmarer

Hello,

I've been trying to make my character to change the view but it is not doing it.

Code: ags
    Isaac.ChangeView(583);
    Display("%d", Isaac.View);

The display it shows the number 583 rightly, but it is showing the normal view of the character. The view 583 is showing other sprites.

I think that this is a kind of bug.

I'm still using the 3.5.1 and the last patch, by the way.

Crimson Wizard

Please tell, in which situation do you call this? What function; and are there any other view-related commands around these lines?

What happens if you use same command elsewhere, for instance, in game_start, or when starting some room which is easy to test, in "before fade-in" event?

Khris

Yeah, in case you animated the character beforehand, don't forget to unlock the view again.
Code: ags
  Isaac.UnlockView();

nightmarer

Quote from: Khris on Wed 11/01/2023 07:31:17Yeah, in case you animated the character beforehand, don't forget to unlock the view again.
Code: ags
  Isaac.UnlockView();
Hello Khris.
It is not the case, because the view is not locked, anyway I tried to do previously and it doesn't work.

nightmarer

Quote from: Crimson Wizard on Wed 11/01/2023 00:54:15Please tell, in which situation do you call this? What function; and are there any other view-related commands around these lines?

What happens if you use same command elsewhere, for instance, in game_start, or when starting some room which is easy to test, in "before fade-in" event?
Hello Crimson Wizard.
This ChangeView is triggered from the GlobalScript as it is something that can run in every room.
But I have just tried to do it in a Load function in a room and it is not working.
I am wondering if the engine gives some troubles when having more than x views in the game.

Crimson Wizard

#5
Quote from: nightmarer on Wed 11/01/2023 16:03:45I am wondering if the engine gives some troubles when having more than x views in the game.

Does it work with any random view, like view 1, 2 etc?
Is it absolutely certain that view 583 does exist?
Sorry for stupid questions, I had to be sure.

BTW, I just wanted to mention, that you don't have to use raw numbers. For each View AGS generates a constant, which name corresponds to view's name in capital letters. For example, if your view is called PlayerView, then it will be PLAYERVIEW, and you can do:
Code: ags
Isaac.ChangeView(PLAYERVIEW);

Cassiebsg

Can you post the entire code in that function?
Maybe you changing it back in another function, or before the function ends?

Are you sure that you have the correct sprites assigned to the view?
I know, stupid question, but happened to me once that my character wasn't changing it's view, and after a long time trying to debug it, I found out that it was changing, there was just a wrong sprite in the view, and it was (by "luck") showing that exact sprite.

Another test you can do, is select another view that is completely different (any view, even if you transform Isaac into a blue cup - just make sure all loops are there and have at least 1 sprite.

Also, are you sure you are are looking at Isaac and not another character that looks exactly like him? (seen that happen as well)

(and now I can't stop thinking about The Love Boat...)  :-[  (laugh)
There are those who believe that life here began out there...

nightmarer

Quote from: Crimson Wizard on Wed 11/01/2023 16:15:06
Quote from: nightmarer on Wed 11/01/2023 16:03:45I am wondering if the engine gives some troubles when having more than x views in the game.

Does it work with any random view, like view 1, 2 etc?
Is it absolutely certain that view 583 does exist?
Sorry for stupid questions, I had to be sure.

Code: ags
Isaac.ChangeView(PLAYERVIEW);
Yes, the 583 exits. I tried to change the number of view and it works with any number, with the 100, 500, 582, even the 584. I'm going to delete the view and create it again to see if it is solved.
I will update you.

Quote from: Crimson Wizard on Wed 11/01/2023 16:15:06
Quote from: nightmarer on Wed 11/01/2023 16:03:45I am wondering if the engine gives some troubles when having more than x views in the game.

BTW, I just wanted to mention, that you don't have to use raw numbers. For each View AGS generates a constant, which name corresponds to view's name in capital letters. For example, if your view is called PlayerView, then it will be PLAYERVIEW, and you can do:

Code: ags
Isaac.ChangeView(PLAYERVIEW);
Oh! I didn't know that. Intead of that I was written myself constants with it. Thank you!

nightmarer

Quote from: Cassiebsg on Wed 11/01/2023 21:12:11Can you post the entire code in that function?
Maybe you changing it back in another function, or before the function ends?

Are you sure that you have the correct sprites assigned to the view?
I know, stupid question, but happened to me once that my character wasn't changing it's view, and after a long time trying to debug it, I found out that it was changing, there was just a wrong sprite in the view, and it was (by "luck") showing that exact sprite.

Another test you can do, is select another view that is completely different (any view, even if you transform Isaac into a blue cup - just make sure all loops are there and have at least 1 sprite.

Also, are you sure you are are looking at Isaac and not another character that looks exactly like him? (seen that happen as well)

(and now I can't stop thinking about The Love Boat...)  :-[  (laugh)
Thank you. It seems to work with every view instead this one, and the sprites are fine. I'll try to create the complete view again to see if this solves the problem.

nightmarer

Well, I just created a new view (585) with exactly the same sprites and now it is working. I don't know why it was not working with the 583. As a test I have deleted the 583 and created back again and it doesn't work again. It seems that this view number is not working, at least in my project.

Crimson Wizard

#10
Quote from: nightmarer on Wed 11/01/2023 22:55:32Well, I just created a new view (585) with exactly the same sprites and now it is working. I don't know why it was not working with the 583. As a test I have deleted the 583 and created back again and it doesn't work again. It seems that this view number is not working, at least in my project.

Is there anything in scripts triggering on view 583? Like some code in repeatedly_execute_* functions, which tests if player's view is 583 and changes it? Perhaps do "Find in project" for "583".

nightmarer

OMG. You were right. There was a function in the repeat_execute_always which was guiding to the function created for the walking sound. There it was an if going to back to the standard character view if it wasn't the standard view.
I don't know why it didn't jump this while debugging.
Thank you!

SMF spam blocked by CleanTalk