Re: TD Levels (with downloads)

Vegas wrote:

Here it is
(contain level file and lua script)

Thanks! Going to test it out right now. I am going to see if I can get it to display it on screen.

Edit: I see in the script that you are trying to get an object named "Unprojected"
Should I create this object? If so where do I put it? what is the purpose of it?

The console is telling me that the object doesn't exist

Last edited by Tutorial Doctor (2013-10-11 16:48:18)

Re: TD Levels (with downloads)

I used GetUnjprojectedPoint example from the wiki
(single project example Here)

"Unprojected" is the cube i use to test collision
If you replace your level file with the one i gave you, it will work (i've just added a cube, and enabled physics for that cube + the 3 others that you want to click)

Last edited by Vegas (2013-10-11 17:01:42)

Re: TD Levels (with downloads)

Vegas wrote:

I used GetUnjprojectedPoint example from the wiki
(single project example Here)

"Unprojected" is the cube i use to test collision
If you replace your level file with the one i gave you, it will work (i've just added a cube, and enabled physics for that cube + the 3 others that you want to click)

Ahh! I was only using the script, not the level file. Thanks! I will look into how it works!

p.s. I did add an uprojected object and it worked (didn't delete the entities however, but I got it to display a font.

Last edited by Tutorial Doctor (2013-10-11 17:10:42)

Re: TD Levels (with downloads)

Thanks Vegas. I was able to get it to display each box when moused over (Also changed the names from Entity... to Box...)

alex = getObject("Alex")
model = getObject("Model")
click = getObject("Click")
text = getObject("Text")

deactivate(model)

Unprojected = getObject("Unprojected")
Camera0 = getObject("Camera0")

function Spin(x)
    if isKeyPressed("D") then
        rotate(x,{0,0,1},3)
    end
    
    if isKeyPressed("A") then
        rotate(x,{0,0,1},-3)
    end
end

function Switch(x,y)
    if isKeyPressed("RIGHT") then
        playSound(click)
        deactivate(x)
        activate(y)
    end
    
    if isKeyPressed("LEFT") then
        playSound(click)
        deactivate(y)
        activate(x)
    end
end

function onSceneUpdate()

    Spin(model)
    Spin(alex)
    Switch(model,alex)
    
--[[----------------------------------------------------------------------UNPROJECTED POINT]]
    mx = getAxis("MOUSE_X")
    my = getAxis("MOUSE_Y")    

    V1 = getUnProjectedPoint(Camera0, vec3(mx, my, 0))
    V2 = getUnProjectedPoint(Camera0, vec3(mx, my, 1))

    point, Unprojected = rayHit(V1, V2) -- note that rayHit only detects objects with physics enabled

    if point then
        Xname = getName(Unprojected)
        Xobj = getObject(Xname)
        setText(text,Xname)
        print(Xname)
        
        if Xname == "BoxR" and onKeyDown("MOUSE_BUTTON1") then deactivate(Xobj) end
        if Xname == "BoxL" and onKeyDown("MOUSE_BUTTON1") then deactivate(Xobj) end
        if Xname == "BoxT" and onKeyDown("MOUSE_BUTTON1") then deactivate(Xobj) end
    end

end

Re: TD Levels (with downloads)

No problem wink

Re: TD Levels (with downloads)

I have been trying to create a script that lets me toggle through characters. I know I have to use a table, but I want to be able to just add any new character object to the table and be able to toggle it. I haven't been able to find out how to use for and while loops in maratis without it crashing (guess I don't understand how the onSceneUpdate function works as it relates to loops.

Re: TD Levels (with downloads)

Tutorial Doctor wrote:

I have been trying to create a script that lets me toggle through characters. I know I have to use a table, but I want to be able to just add any new character object to the table and be able to toggle it. I haven't been able to find out how to use for and while loops in maratis without it crashing (guess I don't understand how the onSceneUpdate function works as it relates to loops.

I haven't tried it yet but chances are you need to use Lua Coroutine's(Multithreading) OpenGL is single-threaded it can only run one process at a time, same with most things in regards to computers. One of two things is going to happen when dealing with pointers(objects) in this case eather A. The program freezes until the process is complete or B. The program crashes.

But then again when Mixing C++ and a Scripting Language(Lua) a program operates completely different than when using one or the other. Anyways Coroutine's ...

http://lua-users.org/wiki/CoroutinesTutorial
http://www.lua.org/pil/9.1.html

Re: TD Levels (with downloads)

Tutorial Doctor wrote:

I have been trying to create a script that lets me toggle through characters.

I did it for you! ;-)
Press TAB to switch between characters.
2_Jules.7zip

Last edited by ant0n (2013-10-16 04:13:58)

Re: TD Levels (with downloads)

ant0n wrote:
Tutorial Doctor wrote:

I have been trying to create a script that lets me toggle through characters.

I did it for you! ;-)
Press TAB to switch between characters.
2_Jules.7zip

I checked it out for a little, but I still have to look at it (the code). I am going to apply this to my Character Select Level. Thanks!

Re: TD Levels (with downloads)

Okay guys, I almost have the Car Level finished, just want to place a character in the passenger seat and maybe some background music. Perhaps a voice over? we will see.

I also figured out how to toggle. I just use booleans with a table.

Last edited by Tutorial Doctor (2013-10-18 00:22:23)

Re: TD Levels (with downloads)

I'm just going ahaead and uploading the car level project file. I uploaded the published version in another post, but this is the project file (in first post).

Last edited by Tutorial Doctor (2013-11-24 04:00:12)

Re: TD Levels (with downloads)

I just tried your car level, pretty good idea to have a free camera inside
the car, that gives a nice layer of immersion wink
That would be interesting to see your level with a more detailed buildings such as this

Good work!

Re: TD Levels (with downloads)

Vegas wrote:

I just tried your car level, pretty good idea to have a free camera inside
the car, that gives a nice layer of immersion wink
That would be interesting to see your level with a more detailed buildings such as this

Good work!

Thank You Vegas. A city like that should be simple to create in Sketchup. I might just use one from the 3d warehouse to start.

I do want to work on this level more, just trying to win this fight with Blender. Hehe.

Re: TD Levels (with downloads)

Just threw the car into St Petersburg:
https://sites.google.com/site/maratisfiles/files/Screenshot%20%28912%29.png

Re: TD Levels (with downloads)

great job!
St Petersburg big_smile

Re: TD Levels (with downloads)

Okay, If only I can figure out how to get these match photo textures into blender correctly. I wonder how assimp treats them?
https://sites.google.com/site/maratisfiles/files/Screenshot%20%28913%29.png

Re: TD Levels (with downloads)

ant0n wrote:

great job!
St Petersburg big_smile

Hehe thanks. This was a quick model for testing. If I can get textures to import into blender or assimp correctly I could have a better looking town (I think the issue is with sketchup) we will see.

Last edited by Tutorial Doctor (2013-12-07 05:49:20)

Re: TD Levels (with downloads)

Finally!!!! I have a human character with an idle and walking animation. I didn't have to code it from scratch because I just used my Customizeable Game Script (one of my topics). The transition doesn't bother me as much as my other test levels.

Of course, my animation skills are not good yet.

(Soldier In St Petersburg)

Last edited by Tutorial Doctor (2013-12-10 08:09:07)