Jump to content

  • Log In with Google      Sign In   
  • Create Account

Nypyren

Member Since 19 Aug 2002
Offline Last Active Yesterday, 07:32 PM

#5313417 Unity C# EditorSceneManager Issue

Posted by on Yesterday, 02:23 PM

MenuItem examples: https://docs.unity3d.com/ScriptReference/MenuItem.html

Basically, just put a [MenuItem("Menu/ItemName")] attribute on a static function. This will create an entry on the Unity editor's main menu that you can click to run the function.

This will let you test your scene closing code. This should let you find out if it's a problem specific to switching from edit->play mode or not.


#5313410 Unity C# EditorSceneManager Issue

Posted by on Yesterday, 01:24 PM

It might be an issue with trying to manipulate the scene during the edit->play transition. Does that code work if you run it from a MenuItem?

How do you define and initialize the sceneName variable? Try also Debug.Logging the sceneName variable to make sure it's still what you expect when that code runs.

Is there anything else happening when the game starts that could be instantly re-opening the scene?


#5312718 Visual studios 2010 debugger variable doesn't update

Posted by on 26 September 2016 - 02:04 PM

That thing that you accidentally clicked might have been something on the "project is out of date, do you want to compile it?" dialog. If that is set to 'never', you could be running an old version of your EXE which doesn't contain any of the new variables you've been adding.

I recommend finding the following setting and making sure it's set to Always Build. If you accidentally changed it to Never Build, then this could be causing some of your problems.

Tools -> Options -> Projects and Solutions -> Build and Run -> On Run, when projects are out of date: --> Always Build


#5312374 Visual Studio C++ without debugging screen fades.

Posted by on 25 September 2016 - 01:05 AM

This attach process idea works well if in a while loop for example, what are its other uses?


A few other cases where I've used attach-to-process:

- When my program starts child processes, I attach the debugger to all of the child processes as well. (I wish visual studio could do this automatically.) The only game examples I can think of where you would start a child process would be when a game client launches its own dedicated server instead of hosting it in-process.

- When a program crashes but I forgot to attach the debugger, sometimes the crash dialog will suspend the program and I can attach at that time to see where the crash is. (As far as I know this is something special that Visual Studio installs.)

- Debugging programs I don't have source code for (using the disassembly window).

- Attaching to a process on a different computer (usually for debugging the program on a Windows RT tablet).


#5312162 Visual Studio C++ without debugging screen fades.

Posted by on 23 September 2016 - 01:46 PM

"Stopped responding" typically means the program's UI thread (the main one, in most windows apps) is looping (or waiting for a synchronization signal) without handling windows messages. The operating system detects programs that haven't processed windows messages in a certain amount of time as "unresponsive".

When the program stops responding, you can attach your debugger to the existing process (Debug -> Attach to Process), then press the 'suspend execution' button (the pause button). Open the Debug -> Windows -> Parallel stacks window and find the main thread, and look at where it's stuck. That should give you a starting point from which you can diagnose the problem.


#5311829 Making a bot for a website in C++?

Posted by on 21 September 2016 - 05:41 PM

It's pretty trivial in any framework that has good HTTP and HTML libraries. I write my web automation tools in C#, for example. I use the HtmlAgilityPack and .Net's built in Http classes.


#5311810 Making a bot for a website in C++?

Posted by on 21 September 2016 - 01:56 PM

A bit more about what you'll need to understand to make a bot for modern web pages:

Interactive web pages are divided into two parts: The part that is downloaded onto your computer (HTML, CSS, javascript) and the part that runs on the web server (the language used on the server side doesn't matter to you because the two sides use a standard method of communication: HTTP).

When you've got an interactive web page, typically what happens is the javascript running on your machine makes requests to the server to transfer data, and then modifies what's being drawn in the browser GUI. Every web page is different. These are the requests that you will need to automate with your bot. In order to find out how those requests work, you will need to analyze the requests being sent. Most browsers come with a built-in set of debugging tools which will let you watch the requests being made.

After you figure out how the requests work, all you need to do is write a program which understands the possible requests that you can make, how to read the data that the server sends to you, and how to send data back to the server.

The most common type of request you'll have to deal with is logging in. Typically you send some credentials in a request, and the server responds with a session token. From then on, you make each subsequent request using that session token.

You may also need to handle cookies. Cookies are similar to session tokens: The server will occasionally give you a cookie, you need to save it on your machine somehow, and then send that cookie with each request after that.

At that point, the rest of the program is entirely up to you to decide on.


#5311806 Making a bot for a website in C++?

Posted by on 21 September 2016 - 01:43 PM

Web browsers consist of:

Making HTTP requests
Executing JavaScript
Parsing and rendering HTML/CSS

A bot needs to:

Make HTTP requests
Parse HTML (sometimes)
Execute JavaScript (extremely rarely)

HTTP requests are EXTREMELY simple compared to the other parts. You can find libraries to do this for you. A bot, instead of rendering the HTML for a user, scans the HTML for the data it's interested in instead. There are libraries for parsing HTML if you need them, or you can use plain text or regular expression searches.


#5311031 How many RAM on VDS server I need setup, then my fb game will support 1000 on...

Posted by on 15 September 2016 - 11:23 PM

At least 1000 bits of RAM.


#5311010 Would you try a language if all you had to do was install a Visual Studio ext...

Posted by on 15 September 2016 - 06:41 PM

Having a VS extension with intellisense and good debugging support is definitely one of my filter criteria for trying languages out. I have an extremely long list of other filter criteria for languages, though. IDE is just one thing to consider.

As an example, since dmatter mentioned F# above: The thing about F# that was a showstopper for me was lack of forward declarations, combined with C-style 'declare before use' instead of breadth-first namespaces/types/functions/bodies compiling like C# does that doesn't care about declaration order except within bodies.



I don't mind having to install both a standalone command-line suite of tools, plus an optional .VSIX. Frequently with serious projects, the command-line tools need to be as easy to install as possible to get them deployed on our CI build machines. Ideally, no environment variables need to be set; usually just adding the PATH entry to the bin folder or having a well-known path that it gets installed to is enough.

For Windows desployment, having an installer for desktop users is MUCH nicer than having a zip file with a README.md that you hope the user has the patience for.


#5310817 Click, hold, pull back, release to fire

Posted by on 14 September 2016 - 01:57 PM

(For context for other readers, the PM he sent me says he's using Unity, so I'm basing this post on that)

Ok, so:

When the user presses the mouse/touch on the ball, keep track of that position (either the ball position or the click position, whichever makes more sense for you) and set a flag that indicates that the user is starting to drag. You'll need either a Vector3 and a bool or a Vector3? (the ? in C# means "nullable", which is sort of like combining a bool and another type in a single variable.) Those variables need to live for multiple frames, so define them as members of a MonoBehaviour class.

When the user moves the mouse while dragging, take the starting position and the current position of the ball/mouse (depending on whether you're moving the ball while you pull or not) and make a vector from that: (start - current). Imagine that subtracting two position vectors creates an arrow between them, pointing towards the first position, from the second position. This will be a vector that represents both the direction and power of the pull. You can use this to draw a line or whatever you want to do to show the user what's happening.

When the user releases the mouse while dragging, set the ball's velocity equal to that vector. Clear your dragging flag, start any additional animations, play a sound, etc. After that, just let Unity's physics engine move the ball normally.


#5310812 Click, hold, pull back, release to fire

Posted by on 14 September 2016 - 01:46 PM

Have you programmed anything before? We need to know what you already know so we can connect our explanations to your knowledge.


#5310807 Click, hold, pull back, release to fire

Posted by on 14 September 2016 - 01:39 PM

That's not how game development works.


#5310045 How can i figure out the coordinates of a projectile after it has moved at an...

Posted by on 08 September 2016 - 05:11 PM

https://en.wikipedia.org/wiki/Polar_coordinate_system#Converting_between_polar_and_Cartesian_coordinates
https://en.wikipedia.org/wiki/Euclidean_vector

A vector is (x,y) in 2D and (x,y,z) in 3D. Sometimes there's a w component but you can ignore that here.

A ray is two vectors: One indicates a staring position, the other indicates the direction of travel.

A line segment is two vectors, but instead of a starting position and a direction, it's a starting and ending position.

Ray-with-other-object collisions usually solve for "t" which is a number indicating how far along the ray the collision occurs, usually in the form: collisionPoint = rayStartPoint + rayDirection * t

A capsule is a box with circles at each end (in 2D) or a cylinder with spheres at each end (in 3D), or in another way of thinking about it, the surface of all points that are a constant distance away from a line segment inside the capsule. The idea here is that instead of trying to collide your ball with a line, you simultaneously shrink the ball to a point and expand the object-to-collide-with by that radius in all directions, and in certain cases this makes the collision equations simpler to solve. When you expand a line segment by a constant radius in all directions, you get a capsule.

The reason why you could use a capsule in a pong game is that the ball might hit one of the ends of the paddle. If you use a plain two-line-segments test, you will get a collision point that isn't quite where the ball will actually collide. The difference will be more extreme the further from perpendicular the ball is moving with respect to the paddle's surface.


#5309998 How can i figure out the coordinates of a projectile after it has moved at an...

Posted by on 08 September 2016 - 01:38 PM

Treat the path the ball will travel as a ray, treat the goal as a line segment, and perform a ray-line segment intersection.

If the ball is a circle with a nonzero radius, you'll have to do ray-capsule intersection instead.




PARTNERS