Monday, 23 September 2019

Programming Adventures 2 - Unity3D Translation

Programming Adventures 2 - Unity3D Translate

When moving objects using gameObject.transform.translate(x,y,z), its direction is based on the object's local transformation.

That means that a square object rotated 90 degrees right will translate +Y when translated by (10, 0, 0).

This bug happens when trying to translate objects using world space vectors.


The solution is to use gameObject.transform.SetPositionAndRotation( gameObject's position + translation direction, __); this avoids the local transformation stack!

Sunday, 22 September 2019

Programming Tricks 1 - PHP and JS/CSS

Programming Tricks 1


When creating PHP scripts, there is a funny error that if there are spaces before the first <?php tag, the session information is sent before the php script is executed.

So if you get:
 [22-Sep-2019 12:09:17 America/New_York] PHP Warning:  session_start(): Cannot start session when headers already sent in /home/esceqrkk/groundstationdatabase/main.php on line 3
 And there is no code before that main.php file, it's due to the spaces.

Javascript + CSS

A super easy way to animate and control your CSS animations is to use css transitions, css variables and jquery all in one go for example:

JQuery side:
        var currentXTranslation = 0;
        $(document).ready(function () {
            $("#NavigateLeftButton").click(function(evt) {
                currentXTranslation += 100;

                $(':root').css('--current-x-translation', currentXTranslation + "vw"); 
CSS Side:
:root {
        --main-bg-color: #141414;
        --current-x-translation: 0vw;

    .Slide {
        transform: translateX(var(--current-x-translation));
        transition-property: transform;
        transition-duration: 3s;
This results in the "Slide" element's transform to be controlled by the JQuery, and the CSS to do the updating.

The difference between class and object.

 The difference between class and object is subtle and misunderstood frequently. It is important to understand the difference in order to wr...