Tags down


Healthbar not decreasing when player is collided with the laser

By : Moran Golan
Date : October 17 2020, 06:10 PM
I wish did fix the issue. HealthBar is of type Slider. CalculatingHealth is a function that does not return anything (so void). You try to set a variable initialy initialized to type Slider to a void value. This is not possible.
You could:
code :
float CalculatingHealth()
    return healthdecrease =  CurrentHealth / MaxHealth;
HealthBar.value = CalculatingHealth();

Share : facebook icon twitter icon

Collision script on an object to be collided with from the player for pickup

By : user3398963
Date : March 29 2020, 07:55 AM
I hope this helps . This function will never get called because your capitalisation is wrong. Capitalise the first letter of the function name.
code :
void OnTriggerEnter(Collider c)
void onTriggerEnter(Collider c)

Detecting whether the player has collided w/ the bottom of an object (rectangles)

By : Vijaya Neti
Date : March 29 2020, 07:55 AM
it fixes the issue Your collision detection is written in a way that allows the last iteration to override all earlier checks. Instead of that, have canMoveUp set to True before the loop, and the loop should only set it to False or leave it alone.

Find out which node (that shares the same category bitmask with other nodes) collided with my player node [Swift & S

By : Shyama Praveena
Date : March 29 2020, 07:55 AM
it fixes the issue Take a look at SCNPhysicsContact and SCNPhysicsContactDelegate. That will give you the exact nodes that collided.

In my simple game, the player always erases the laser warnings, and I cannot seem to fix it.

By : john peters
Date : March 29 2020, 07:55 AM
To fix this issue Working project here: https://jsfiddle.net/ay7kp7yb/1/
I think the best approach to solve this problem is to work with the classic pattern. That way all events that occur in the game need to be chained to a main loop (see: Game Loop).
code :
while (true)
// game states

// current state
var gameState = STATE_TITLE_SCREEN;

// time of the current state
var gameStateTime = 0;

// change the state and reset the time of last state
function setGameState(state) {
    gameState = state;
    gameStateTime = 0;
var minIteractionTime = 10;
var mainGameLoop = setInterval (function () {

    switch (gameState) {

        case STATE_TITLE_SCREEN:
            // Title screen (on press space bar, change gameState to STATE_GAME_STARTING)

            // Starting game, reset variables, countdown to start, etc...
            score = 0.0;

            // run the game after 5s
            if (gameStateTime>5000)


        case STATE_RUNNING:
            score += (0.1/100.0);  // 0.1 points after 100 miliseconds

            // CLEAR THE SCREEN HERE

            player.draw(); // draw the player ONLY here
            laserWarning.draw(); // Draws the warnings AFTER draw the player
            laserbeam.burn(player); // try to burn the player

        case STATE_PLAYER_DYING:
            // player dying animation..

            // after 5s, change show the game over screen
            if (gameStateTime>5000)

            // draw the game over screen here

            // after 5s returns to the title screen
            if (gameStateTime>5000)

    // add the loop time in the gameStateTime variable
    gameStateTime += minIteractionTime;

}, minIteractionTime);
LaserWarning.prototype.draw = function () {
    this.warningTime += minIteractionTime;

    if (this.warningTime>100) {
        // draw the warning only after firsts 100ms

    if (this.warningTime>=750) { // warning time
        // timer reset
        this.warningTime = 0;

Laserbeam.prototype.burn = function (player) {
    this.warmingUpTime += minIteractionTime;

    if (this.warmingUpTime>=750) { // same time of warning

        // draw the laser

        // check if burns the player
        if (player.checkWallCollision()) {
var gameKeys = {
    37: "left",
    38: "up",
    39: "right",
    40: "down",
    32: "space"

// for all iteractions, check the current state
$("body").keyup(function (event) {

    var lastKey = gameKeys[event.keyCode];

    switch (gameState) {
        case STATE_RUNNING:
            if (lastKey === "left") {
            } else if (lastKey === "right") {
            } else if (lastKey === "up") {
            } else if (lastKey === "down") {

        case STATE_TITLE_SCREEN:
            if (lastKey=="space")

Trigger an event if the collided object has the tag "Player"

By : Claudio D.
Date : March 29 2020, 07:55 AM
Does that help I have a trigger zone around a spider terrarium in my game and would like that to trigger the spider's animation when the player walks into the trigger, here is my attempt, but it is returning an error "The name 'col' does not exist in the current context". in advance! ,
The name 'col' does not exist in the current context
code :
private void OnCollisionEnter(Collision collision)
    if (col.gameObject.tag == "Player")

private void OnCollisionEnter(Collision collision)
    if (collision.gameObject.tag == "Player")

Related Posts Related Posts :
  • Why Unit Testing Assert.AreEqual() method does NOT pick up my own Equals() method in the customized class
  • Unity Error: Feature 'out variable declaration'
  • What happens if my C# switch expression is non-exhaustive?
  • How Can I Select an ItemTemplate Based on a Value?
  • EF Class table name and column have same name
  • Substring issues - input string was not in a correct format
  • C# Asynchronously read data from a redirected StandardOutput
  • The code after await operation is not executing
  • Image FILL logic such as "Stretch.Uniform" of WPF
  • Why am I allowed to declare a variable with the same name?
  • Simplest way to display colored 3D boxes in winforms
  • Conventions on having both an API and MVC project in .NET Core solution
  • File upload .NET Core 'IFormFile' does not contain a definition for 'CopyToAsync' and no extension method
  • Deserialize only valid objects by ignoring errors
  • How to write into text file what is ordered by years
  • Remove this 'return' statement or make it conditional
  • Cannot implicitly convert type "System.DateTime" to "LearnScan.LearnUser.NullableDateTime"
  • Why does DateTime.UtcNow.Subtract give me a massive number sometimes?
  • How to restart CancellationTokenSource after make it cancel in c#?
  • Same data is fetched from the database every time
  • JSON Deserialize is not working with List object
  • Convert Visual Studio 2017 C# solution / project for use with Mono on Linux?
  • Sort list by multiple variables
  • How valid is it to use `Result` inside `Task.Run`
  • how to put a variable in the image source in C# like we do in php
  • How to display an image stored in database as bytes into a View?
  • MVC issue for accessing the data from database:The parameters dictionary contains a null entry for parameter 'id' of non
  • Is there a method to group 4 controls into an UserControl or template and use it in parent UserControl and bind them wit
  • Xamarin Forms : can Prism and ReactiveUI be used in the same project ? If so, is it a good idea?
  • How can I paste the "plain" text of a string to int? C#
  • How to determine which table a column belongs to in an SQL Statement given metadata information and parse tree from SQL
  • How to fix The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statemen
  • AutoHotkey: Remap shortcut for MS Visio to align manually selected objects to the top (as if pressing: "AlignTop&qu
  • Can .csproj Switch native code by platform?
  • how to upload multiple files using a single upload control in a MVC application
  • How to use HttpClientFactory with AutoRest generated client
  • Parsing a phrase with Sprache(Words seperated by spaces)
  • called from Blazor client HttpClient.GetJsonAsync returns (with data), but then times out
  • Two processors can't log the information at the same time by using NLog
  • C# streamreader read data multiple times
  • Why are .cshtml changes are not reflected locally until app pool recycle? Why did building my project in Visual Studio s
  • How to make a specific order for calling methods?
  • Why OnCollisionEnter2D / OnTriggerEnter2D don't work?
  • how to use async and await so that it will create a different task or each request
  • Should unit tests tests the functionality of a method?
  • ILGenerator emiting call GetHashCode on int
  • How to register singleton factory resolving scoped objects in ASP.NET Core?
  • How to use C# 6.0 or 7.0 in an old ASP.NET Website (not Website Project)
  • How to ensure that the WCF service will not communicate to the database in parallel
  • Removing items from LinkedList<>
  • Can you instantiate another class within the constructor?
  • Best way to instantiate a class with a private object that needs instantiating as well
  • C# Memory Issues
  • Should a input object be cloned if it is the return value?
  • How to pass c# decimal to sql decimal(4,2)
  • Blazor Component TwoWay Databinding
  • Is there a data structure in C# like a ConcurrentQueue which allows me to await an empty queue until an item is added?
  • how can I create sharepoint lists using c# without using DLLs like Microsoft.SharePoint.Client and Microsoft.SharePoint.
  • How to make Dispose await for all async methods?
  • Getting the `HttpContext` from a generic handler with an `HttpModule`
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk