Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate Method does not execute
    text
    copied!<p>I'm very new to C# and have started a tutorial for the base of my game which all went well... was using Unity but annoyed me too much so plain code it is.. I copied code from Unity which is now error free and all looks good. I've had multiple problems which so far i have managed to resolve but there is now one which i can not find a solution for anywhere, or even someone with the same problem..</p> <p>Basically my game begins with a windows form, which instantiates (I think is the word..) a Class called Game. Game contains the main code for drawing, creating the objects in the game etc.</p> <p>This runs properly, and everything in the Update Method there runs properly, but another Class 'Ship' is created which also contains a Update method (worked like this in tutorial). After editing my game all of a sudden the Update method in the Ship class just does not execute. As far as I thought having '<code>public void Update() {//code}</code>' would run every game step, but not anymore.</p> <p>So my problem: Update method in an instantiated Class does not run.</p> <p>as I said i'm very new to C# (also my first post here) but I will provide as much detail below now if more is required, sorry if it's useless just dunno what would really be related:</p> <p>Update method in Game class runs fine:</p> <pre><code>protected override void Update(GameTime gameTime) { cameraPosition = new Vector3(ship.position.X - ship.direction.X * 12, ship.position.Y - ship.direction.Y, ship.position.Z - ship.direction.Z * 12); viewMatrix = Matrix.CreateLookAt(cameraPosition,ship.position, Vector3.Up); base.Update(gameTime); } </code></pre> <p>and code in the instantiated Ship (will not execute):</p> <pre><code> public void Update() {//code here isn't important i think, i will provide if requested its just that there is a lot and i inserted a breakpoint in the "Update()" line which is never executed therefore this code is never reached.. } </code></pre> <p>both Classes are instantiated like this: Game game = new Game();</p> <p>Sorry I'm not really sure what else to provide, this is really confusing? O.o code in the Ship Class IS executed, just not the Update method.. No warnings or other errors, game plays just wont execute this class' Update code</p> <p>.. Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload