unit – Make an ice cream or frosting effect

Thanks for contributing a response to Game Development Stack Exchange!

  • Please make sure answer the question. Please provide details and share your research!

But avoid

  • Ask for help, clarification or respond to other answers.
  • Make statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

For more information, check out our tips on how to write great answers.

unit: how to make a timer count down and instantiate only 1 precast in x seconds?

I am struggling with my code because I counter 2 problems.
One if the countdown reaches 2, it is instantiated as unlimited game items.
The second is that if _spawnTime reaches 2, it does not equal _resetTime to 0 for it to repeat.

This is my code so far:


(Header("Spawn Object"))
public GameObject _SplatterRock;
public GameObject IvanChar;
(Space)
(Header("Spawn Position"))
public Vector3 _spawnPosition;
(Header("Spawn Options"))
public float _spawnTime = 2f;
public float _resetTime = 0f;
public bool _stopSpawning = false;

private void Update()
{
    if(_spawnTime >= _resetTime)
    {
        _spawnTime -= Time.deltaTime;

        if (_spawnTime <= 0f && !_stopSpawning)
        {
            GameObject _spawnedSplatterRocks = Instantiate(_SplatterRock, _spawnPosition, Quaternion.identity) as GameObject;
            _spawnTime = _resetTime;
            _stopSpawning = false;
        }
    }
}

unit: why can I still call a coroutine from another script, even though I marked it private?

I have this private coroutine in my WinDialogue script:

private IEnumerator ActivateStars(int count)
{
    for (var index = 0; index < count; index++)
    {
        _stars(index).SetActive(true);
        yield return new WaitForSeconds(.3f);
    }
}

And somehow I can still call it from my UIManager script:

_winDialogue.GetComponent().StartCoroutine("ActivateStars", starCount);

How can that be if I marked it private?

Unit tests: constructor injection with fake objects: bad tests?

In The Art of Unit Testing, 2nd Ed., The author gives the following example to inject a chunk using constructor injection and a "fake object". The goal of the "fake object" is to inherit the interface and break dependencies so that you can test it unitarily.

I don't understand how these are examples of legitimate evidence. The call to LogAnalyzer.IsValidLogFileName() used at runtime would call some implementation of IExtentionManager.IsValid(), which would interrogate the string in some way before returning a bool or throwing an exception. So for me the important test here is: for IsValidLogFileName()Does the method return what you expect when you give it a specific string?

In the examples below, the author encodes and establishes myFakeManager.WillBeValid within the tests for truepass myFakeManager to the LogAnalyzer and immediately states that what they have just established myFakeManager.WillBeValid to is true… What did they literally put it to ?!

How are these tests in LogAnalyzerTests.cs Useful?

LogAnalyzer.cs

public class LogAnalyzer
{
    private IExtensionManager manager;
    public LogAnalyzer(IExtensionManager mgr)
    {
        manager = mgr;
    }

    public bool IsValidLogFileName(string fileName)
    {
        return manager.IsValid(fileName);
    }
}

IExtensionManager.cs

public interface IExtensionManager
{
    bool IsValid(string fileName);
}

FakeExtensionManager.cs

internal class FakeExtensionManager : IExtensionManager
{
    public bool WillBeValid = false;
    public Exception WillThrow = null;

    public bool IsValid(string fileName)
    {
        if (WillThrow != null)
            throw WillThrow;

        return WillBeValid;
    }
}

LogAnalyzerTests.cs

(Test)
public void IsValidFileName_NameSupportedExtension_ReturnsTrue()
{
    FakeExtensionManager myFakeManager = new FakeExtensionManager();
    myFakeManager.WillBeValid = true;

    LogAnalyzer log = new LogAnalyzer(myFakeManager);

    bool result = log.IsValidLogFileName("short.ext");
    Assert.True(result);
}

(Test)
public void IsValidFileName_ExtManagerThrowsException_ReturnsFalse()
{
    FakeExtensionManager myFakeManager = new FakeExtensionManager();
    myFakeManager.WillThrow = new Exception("this is fake");

    LogAnalyzer log = new LogAnalyzerConstructor(myFakeManager);
    bool result = log.IsValidLogFileName("anything.anyextension");
    Assert.False(result);
}

pr.probability: What is the most unpleasant i.i.d sequence in the unit cube?

There are lots of concentration results for independent sum sums with scalar value $ X_1, X_2, ldots, X_N $ with $ mathbb E (X_n) = 0 $. For example, the Hoeffding inequality says if all $ | X_1 | le 1 $ so $ mathbb E left ( left | sum_ {i = 1} ^ N X_i right | right) = O ( sqrt N) $.

These concentration results can be generalized, for example, to random variables with vector values ​​with $ | X_n | le 1 $ for $ | cdot | $ The Euclidean norm.

Suppose we have $ | cdot | _ infty $ limits of the norm that means $ X_1, X_2, ldots, X_N in mathbb R ^ d $ are independent with $ mathbb E (X_n) = 0 $ Y $ | X_n | _ infty le 1 $. As $ | X_n | _2 le sqrt d | X_n | _ infty le sqrt d $ we can use concentration results so that the Euclidean norm can $ mathbb E left ( left | sum_ {i = 1} ^ N X_i right | _ infty right) = O ( sqrt {dN}) $.

Does anyone know an example of when this dependency on $ sqrt d $ does it actually happen?

I suspected it would happen if we just said $ X_n = (B_1 ^ 1, ldots, B ^ 1_d) $ for all $ B ^ i_j $ independent and taking values $ pm 1 $ with probability $ 1/2 $. However, the expectation seems more $ O ( sqrt { log (d) N}) $. To see this apply scalar concentration to each $ j $ Coordinates to obtain, up to coefficients:

$$ P left ( Big | sum_ {i = 1} ^ N X_i Big | _ infty <t right) = P left ( text {all} Big | sum_ {i = 1} ^ N X_i (j) Big | <t right) = prod_ {j = 1} ^ d P left ( Big | sum_ {i = 1} ^ N X_i Big | <t right ) ge (1-e ^ {- t ^ 2 /Nálisis)^d.$$

$$ mathbb E Big | sum_ {i = 1} ^ N X_i Big | _ infty = int_0 ^ infty P left ( Big | sum_ {i = 1} ^ N X_i (j) Big | _ infty> t right) dt le int_0 ^ infty (1- (1-e ^ {- t ^ 2 / N}) ^ d) dt $$

I don't know if the integral has a closed form. What I do know is that the same argument gives
$$ mathbb E Big | sum_ {i = 1} ^ N X_i Big | _ infty ^ 2 le int_0 ^ infty (1- (1-e ^ {- t / N}) ^ d) dt $$

I know how to solve Substitute $ x = e ^ – t / N} $ To get $ dt = – (N / x) dx $ and the integral becomes

$$ N int_0 ^ 1 frac {(1- (1-x) ^ d)} {x} dx $$

which is the same $ N $ times the $ d $-th harmonic number, which is $ O (N log d) $. So, we have $$ mathbb E Big | sum_ {i = 1} ^ N X_i Big | _ infty ^ 2 le O left (N log (d) right) $$ and because of Jensen's inequality $$ mathbb E Big | sum_ {i = 1} ^ N X_i Big | _ infty le O left ( sqrt { log (d) N} right). $$

simple unit animation with images

Thanks for contributing a response to Game Development Stack Exchange!

  • Please make sure answer the question. Please provide details and share your research!

But avoid

  • Ask for help, clarification or respond to other answers.
  • Make statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

For more information, check out our tips on how to write great answers.

unit: how can I set the position of each next object to scale to the last object to scale the final scale position?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScalingManager : MonoBehaviour
{
    private List positions = new List();

    // Start is called before the first frame update
    void Awake()
    {
        var ObjectsToScale = GameObject.FindGameObjectsWithTag("Scaling Object");



        // Scale amount of the prefab before - 0.5F
        // For example : The scale amount of the prefab before is 10 
        // So the end scaling position is 10 - 0.5f = 9.5f
        // So the next prefab should start scaling at position
        // new Vector3(scale amount - 9.5f, objecttoscale.transform.y ,objecttoscale.transform.z );

        for(int i = 0; i < ObjectsToScale.Length; i++)
        {
            positions.Add(ObjectsToScale(i).transform.localPosition);
        }

        for (int i = 1; i < positions.Count; i++)
        {
            ObjectsToScale(i).transform.localPosition = new Vector3(
                ObjectsToScale(i - 1).transform.localPosition.x, 0, 0);
        }
    }

    // Update is called once per frame
    void Update()
    {

    }
}

The first object to scale in the original position of the array is in this case 0,0,0 but it could be any position, for example 11,22, -5 but in this case it is 0,0,0

The second object to scale the original position is 12.4, 0.5, -7.39

Both objects are scaled at the same time when the game is run. The first is scaled in the correct direction, the second is scaled in the downward direction.

This is a screenshot of the first object to scale the inspector settings. The start position is 0,0,0 and the red circle shows the position of the final scale on the right:

First scale object

The second screenshot showing the second object to scale information:

Second scale object

And the last screenshot is what I want to do. I want the second object to scale to start scaling, the position will be where the red circle is in the first screenshot. Therefore, each object to scale if there will be 20 objects to scale each object to scale should start scaling from the final scaling position of the object to be scaled earlier in the array.

So it must start from the second: ObjectsToScale1 put it in the red circle at the end position of ObjectsToScale (0)

Then ObjectsToScale2 must be placed at the end scale position of ObjectsToScale1.

I like this :

Like this shape example

The upper red circle shows where ObjectsToScale (0) ends and ObjectsToScale1 begins. The lower red circle shows where ObjectsToScale1 ends and ObjectsToScale2 begins.

ObjectsToScale2 is scaling to the left.

Right, down, left

So if I have 3 objects to scale and set them to scale: Right, Down, Left, no matter what the starting position of each is, it should create the last screenshot form.

The same idea if I have 7 objects to scale: Left, Down, Right, Up, Right, Down, Down. Connect them all from the end of the previous one.

unit: how do people get their game ideas?

One thing that always stops me when I want to start making a game is having no idea what to do. How do people get ideas for their game? I mean realistic ideas for people who are alone with minimal resources (no money for assets, blender and unit). I will never fail to be impressed with all the crazy new concepts, mechanisms or ideas from independent game developers that come up, like making games with random everyday objects. I wish I could do that.

How can I disable the red X button on the unit?

I just want to know how to disable the red X button in the game window using the unit, to prevent the player, for example, from closing the game.

So if anyone knows how to do it, any help would be greatly appreciated.

How do I test unit phtml?

I have a very simple phtml file like

getCondition()): ?>
foo

bar

I want to write an automated test to check if block-> getCondtion is true, we render foo. How can I write such a test?