# First game problems

**URL:** <https://forum.defold.com/t/first-game-problems/18605>\
**Category:** Questions\
**Created:** [April 4, 2018, 12:24pm UTC](https://forum.defold.com/t/first-game-problems/18605 "2018-04-04T12:24:48Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 6, 2018, 2:51pm UTC](https://forum.defold.com/t/first-game-problems/18605/41 "2018-04-06T14:51:54Z")

</div>

Ok, so could it be that the game object has actually spawned but that it’s outside the range of what’s shown by the camera?

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 7, 2018, 9:56am UTC](https://forum.defold.com/t/first-game-problems/18605/42 "2018-04-07T09:56:49Z")

</div>

@britzl to the rescue again 🙂  
It’s not that it wasn’t rendered, but your post did give me an idea. I am using a shader as a background for a galaxy like effect, but the thing is, that I rotated the shader the same amount as the camera, so it wouldn’t look distorted. And because of that When I spawned the objects if they were far ahead, they were spawned behind so they weren’t visible until they moved down…

Well this forum has been extremely nice and using Defold is getting easier by the day for me, so as a small token of thanks I wanted to post about it on a facebook group that I am part of “Indie Game Developers” The reactions were mostly good, a lot of people seem to only now about Unity and Unreal, but a lot of them are willing to check out new stuff 😃

 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/d/dff8bcd28111e9062dcf998f7196c5851a6d1ce7.png)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 7, 2018, 9:58am UTC](https://forum.defold.com/t/first-game-problems/18605/43 "2018-04-07T09:58:42Z")

</div>

Cheers! Thank you for the kind word!

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 9, 2018, 10:15am UTC](https://forum.defold.com/t/first-game-problems/18605/44 "2018-04-09T10:15:50Z")

</div>

Well Here I am again 😃

 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/9/934b991accc16e1d4107acf8a33042771e601166.png)

Ran into a WebGL problem I think… anyone got any ideas?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 9, 2018, 10:40am UTC](https://forum.defold.com/t/first-game-problems/18605/45 "2018-04-09T10:40:42Z")

</div>

What kind of changes have you made since you had it running last?

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 9, 2018, 11:01am UTC](https://forum.defold.com/t/first-game-problems/18605/46 "2018-04-09T11:01:06Z")

</div>

Imported FB Instant Game Library, Removed Shader, Added Emitter.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 9, 2018, 11:08am UTC](https://forum.defold.com/t/first-game-problems/18605/47 "2018-04-09T11:08:08Z")

</div>

And if you backtrack a bit? My guess is that it has to do with “Removed Shader”

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 9, 2018, 11:10am UTC](https://forum.defold.com/t/first-game-problems/18605/48 "2018-04-09T11:10:42Z")

</div>

Yes definitely possible, but I think I have to retract my statement. Looks like the last version that worked in a HTML5 Build that I actually published was before the 3D Objects I added.  
Meaning also before the new camera Rendercam.  
Is it possible I forgot to import some kind of WebGL Libraries or something?

Also, it seems to partly work in Edge (Partly as in it renders and the game is playable, although there is no 3D object, but my 2d objects are rendered in 3D space), but not at all in chrome.

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 9, 2018, 11:32am UTC](https://forum.defold.com/t/first-game-problems/18605/49 "2018-04-09T11:32:39Z")

</div>

@britzl  
I found this in one of your GitHub Repositories  
[https://github.com/britzl/defold-screenshot/blob/master/screenshot/include/GLES2/gl2.h](https://github.com/britzl/defold-screenshot/blob/master/screenshot/include/GLES2/gl2.h)

Lines 447 and 590 seem to be where the problem might be… Thought it might help 🙂  
No idea if it’s the right place or what the reason could be though…

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [April 9, 2018, 11:49am UTC](https://forum.defold.com/t/first-game-problems/18605/50 "2018-04-09T11:49:37Z")

</div>

The error you are getting with `getProgramParameter` etc might have something to do with your shaders not using some of the `uniform`/constants that are exposed in the material file.

Iirc, WebGL might be a bit picky when it comes to shader uniforms/constants that are defined in the material and set/updated through scripts, but not actually used in the shader code…

Are you using the built-in material for your 3D model?

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 9, 2018, 11:51am UTC](https://forum.defold.com/t/first-game-problems/18605/51 "2018-04-09T11:51:02Z")

</div>

Yes, I am using the default material

 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/a/a97c6236b251ae9d2d0466fdf905578c308d1c71.png)

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 9, 2018, 1:35pm UTC](https://forum.defold.com/t/first-game-problems/18605/52 "2018-04-09T13:35:34Z")

</div>

Well, this does seem to be the problem, although I don’t understand how or why… I Removed the 3D object and now the game loads fine and works well (but is sorta useless without the main “character” 😅 ) Should I go about making a completely new material or change the shader…

No idea how to proceed here…  
I will try the 3D manual again, perhaps I messed something up and I will also look at the other 3D game that helped me before to see if I can figure anything out 🙂

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [April 9, 2018, 1:59pm UTC](https://forum.defold.com/t/first-game-problems/18605/53 "2018-04-09T13:59:33Z")

</div>

I might have found an issue.

There seems to be a difference in precision between the vertex and fragment shaders for our built in model material. In the vertex shader (model.vp) the uniforms are specified as `mediump` while in the fragment shader (model.fp) they are set to `lowp`…

Could you try to do the following:

1. Copy `model.fp` and `model.material` from the `builtins/materials/` directory, into somewhere under your project.
2. Open your newly copied `model.material` file and change the “Fragment Program” to point to the `model.fp` file you copied.
3. For every model component you have in your game, change the material to your own copy of `model.material`. You probably only need to change your character model if this is the only 3D model you are using in your game.
4. Open your new `model.fp` file and change the following rows:

```lua
uniform lowp sampler2D tex0;
uniform lowp vec4 tint;
uniform lowp vec4 light;

```

into

```lua
uniform mediump sampler2D tex0;
uniform mediump vec4 tint;
uniform mediump vec4 light;

```

If you were having the same issue as me, this should hopefully make it work on HTML5. Let me know how it goes!

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 9, 2018, 2:11pm UTC](https://forum.defold.com/t/first-game-problems/18605/54 "2018-04-09T14:11:06Z")

</div>

Fixed the problem completely. I will try uploading the game to see what happens, but now the build seems to work nicely.

What I did at first was change from the regular model.material, to the model.material in the render folder that I took from the Tans VS Meteors Project, but it turned out to only partly fix the problems and the lights didn’t work as well as they should…  
But doing what @sven wrote here worked perfectly, model rendered well and with correct lighting.  
Thank you 🙂

@sicher Hey I saw your [post about tutorials](https://forum.defold.com/t/call-for-tutorial-and-sample-suggestions/18763) and how 3D is definitely planned, just wanted to mention this what sven posted here could be added to it 🙂

Cheers!

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 10, 2018, 11:30am UTC](https://forum.defold.com/t/first-game-problems/18605/55 "2018-04-10T11:30:08Z")

</div>

I did some improvements on my little Defold test game I am working on 😃

> **[Tap Climb Defold by Greaneagle](https://greaneagle.itch.io/tap-climb-defold)**
>
> Tap Climb Made in Defold

Works nicely now, changed the camera to follow the player and some other improvements to make it look slightly better and smooth.

And now the big one comes: How to make it playable on my facebook messenger with Instant games?  
I saw the manual [Facebook Instant Games | Defold](https://www.defold.com/manuals/instant-games/)

But I am stuck at this:

 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/5/5cb6a0f43cd5dd2ed4862e75258fd02baf0913e1.png)

I have the Facebook app configured, have my FB ID but don’t know how to add this part to the Bundle that I build.

Also, do I need to fbinstant.initialize if I don’t want to use any of the FB API Functions yet?  
I just want to be able to play the game in the messenger for now.

Cheers!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 10, 2018, 11:48am UTC](https://forum.defold.com/t/first-game-problems/18605/56 "2018-04-10T11:48:46Z")

</div>

Have you added the extension-fbinstant as a dependency according to the instructions? Next do a Fetch Libraries. You should now see a read only folder in your Assets named fbinstant. In this folder there’s a sample index.html file that you can use that already includes the Instant Games SDK. Open game.project and scroll down to the HTML5. Browse and select the index.html file.

> [@greaneagle](#):
>
> Also, do I need to fbinstant.initialize if I don’t want to use any of the FB API Functions yet?  
> I just want to be able to play the game in the messenger for now.

It’s fine for testing purposes to not call any of the FB IG API functions.

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 10, 2018, 12:22pm UTC](https://forum.defold.com/t/first-game-problems/18605/57 "2018-04-10T12:22:15Z")

</div>

Yes, I did have the libraries added, I also did fetch them again and there is this folder in my Assets:

 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/2/2653a8820da1fcda89ed37ecc8f0bc7fd6e63720.png)

In there is the Index HTML, that I added in the game.project file here:

 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/0/0a004eac73284820880cf646324d46683006048a.png)

But now I get this build Error…  
 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/7/7043ffc10f2dd1569f2036105e47cf590e0355a3.png)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 10, 2018, 12:24pm UTC](https://forum.defold.com/t/first-game-problems/18605/58 "2018-04-10T12:24:17Z")

</div>

My guess is that it’s the spaces in the folder name. Move your project to a folder without spaces.

---

<div class="post-metadata">

**Author:** ![greaneagle](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/g/8e8cbc/32.png) [@greaneagle](https://forum.defold.com/u/greaneagle)\
**Post date:** [April 10, 2018, 12:30pm UTC](https://forum.defold.com/t/first-game-problems/18605/59 "2018-04-10T12:30:40Z")

</div>

Nope, looks like that didn’t fix it…  
 ![image](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/2X/8/8869b2e3a1e8b457ebd1f86d037545c5969422e4.png)

This is odd… no special characters anywhere in the Path and still I get this error…

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 10, 2018, 12:33pm UTC](https://forum.defold.com/t/first-game-problems/18605/60 "2018-04-10T12:33:34Z")

</div>

Hmm, @Mathias_Westerdahl and @Erik_Angelin, it looks like it is searching the local file system and not inside the dependency. Any idea why?

[Previous page](https://forum.defold.com/t/first-game-problems/18605.md?page=2)

[Next page](https://forum.defold.com/t/first-game-problems/18605.md?page=4)
