For my undergrad final project I want to develop an educational game for teaching basic programming so I want to provide them some easy drag'n'drop visual programming editor like in this code it but i have no idea how to do this i'm new in unity and i did a lot of search in google but i didn't get it ( i'm quite loste ) .so please can any one help me in these and give me a clue so i can build on it. thank you for your help
this is a example for my game design expl ( i want to move the player by drag and drop move right , move up ,move forward ......). I home my idea and question are clear
A few months ago I developed a project very similar to yours. I recently extrapolated a library from this project and published it on github. the library is called blockly-gamepad 🎮 and allows you to create the structure of a game with blockly and to interact with it using methods such as play() or pause().
I believe this will greatly simplify the interaction between blockly and unity, if you are interested in the documentation you can find the live demo of a game.
blockly-gamepad 🎮
live demo
Here is a gif of the demo.
How it works
This is a different and simplified approach compared to the normal use of blockly.
At first you have to define the blocks (see how to define them in the documentation). You don't have to define any code generator, all that concerns the generation of code is carried out by the library.
Each block generate a request.
// the request
{ method: 'TURN', args: ['RIGHT'] }
When a block is executed the corresponding request is passed to your game.
class Game{
manageRequests(request){
// requests are passed here
if(request.method == 'TURN')
// animate your sprite
turn(request.args)
}
}
You can use promises to manage asynchronous animations.
class Game{
async manageRequests(request){
if(request.method == 'TURN')
await turn(request.args)
}
}
The link between the blocks and your game is managed by the gamepad.
let gamepad = new Blockly.Gamepad(),
game = new Game()
// requests will be passed here
gamepad.setGame(game, game.manageRequest)
The gamepad provides some methods to manage the blocks execution and consequently the requests generation.
// load the code from the blocks in the workspace
gamepad.load()
// reset the code loaded previously
gamepad.reset()
// the blocks are executed one after the other
gamepad.play()
// play in reverse
gamepad.play(true)
// the blocks execution is paused
gamepad.pause()
// toggle play
gamepad.togglePlay()
// load the next request
gamepad.forward()
// load the prior request
gamepad.backward()
// use a block as a breakpoint and play until it is reached
gamepad.debug(id)
You can read the full documentation here.
I hope I was helpful and good luck with the project!.
EDIT: I updated the name of the library, now it is called blockly-gamepad.
Your game looks cool!
For code-it, we are using Blockly as the code editor. The code is then executed by a Lua interpreter inside the game. You could do something simpler: make one block type for each action, like MoveForward etc. and have them generate function calls like SendMessage('gameInterfaceObject','MoveForward'). In the game you need an Object that listens for such messages from the website.
Here's how your game talks to the website:
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
Related
Firstly I'm still fairly new to coding, saw people making games and fell in love with the idea of making your own game. So the past few months I've been learning unity tutorials and practicing basic games. I've come so far to be basically done with my first game. Everything is ready and I want to load and post it on playstore, but there's one last issue. When I run it on Unity on my pc it looks perfect but I loaded it onto my phone and the UI and some objects is either not showing or looking different than on the pc.Example1Example2Example3 These are examples of my problem. The IMG above is the way it should look like and the one underneath is how it shows on my phone when loaded.
It doesn´t look the same, due to the different resolutions.
Try to use a Canvas Scaler component. Set a reference resolution and the mode how you want to scale it.
If you want your UI elements to be anchored to the center/top/left etc. you should also set the anchor points. Here is a good Tutorial
A good way to instantly check the result is the "device simulator" It is a unity package
That's because of your Canvas settings & your UI GameObjects Anchor. But I think the easiest way to solve this for you - because you don't have that much experience about it - is to separate canvases for mobile & pc. This is the code:
private void Start()
{
if (Application.platform == RuntimePlatform.WindowsPlayer) // If your game's running on android
{
pcCanvas.SetActive(true); // Use PC designed canvas
mobileCanvas.SetActive(false); // Disable Mobile designed canvas
}
else // Your game is running on mobile
{
pcCanvas.SetActive(false);
mobileCanvas.SetActive(true);
}
}
Add this to a GameObject, Design 2 Canvases & assign them to script. (This will be a litte complicated, but will work) This link for more info
But if you want to use 1 canvas, you have to set its settings & its GameObjects anchors.
I'm learning UE4 C++ Development and I have a idea but I don't know if that is possible to make. I have a folder on my WAMP SERVER for exemplo ( C:\wamp\www\staticmesh\My3DModel.3DS ). My idea is create a button on my UE4 widget and when It's pressed it import my Static Mesh from my folder to my currently scene. It's possible ?
OBS: because my game will be too heavy, so I thought I would import the static meshs and put in the scene in real time, without building next to the game. If you know another solution or any idea it will be welcome. **
Would Somebody be willing to helping me step by step How could I implementing that code below ? It's very very important to me, because I'm learning UE4 C++.
// Load Static Mesh From Path
static FORCEINLINE UStaticMesh* LoadMeshFromPath(const FName& Path)
{
if(Path == NAME_None) return NULL;
//~
return LoadObjFromPath<UStaticMesh>(Path);
}
Thank you so much for any answer.
You are asking a bit much if all you did yet is draw that sketch.
If you did more already please share the information.
I recently answered what I could identify as core part of your question tho - how to get the mesh from local drive into ue4 -
https://stackoverflow.com/a/41753091/5196012
This also features the link to the wiki where your code sample seems to come from.
You are missing the template the person has on the wiki
//TEMPLATE Load Obj From Path
template <typename ObjClass>
static FORCEINLINE ObjClass* LoadObjFromPath(const FName& Path)
{
if(Path == NAME_None) return NULL;
//~
return Cast<ObjClass>(StaticLoadObject( ObjClass::StaticClass(), NULL,*Path.ToString()));
}
Since no one knows what selectionstrategy you have I guess it will be some standard file browser dialog returning a file handle...
All you would need to do then is to call your function in the widget button "on pressed" event.
OBS: because my game will be too heavy, so I thought I would import the static meshs and put in the scene in real time, without building next to the game.
That is not possible. The moment you import a static mesh it will be saved as a .uasset file in your content folder.
How big are your meshes and how small is your disk that you cannot import them?
If you absolutely do not want to import any assets you can generate your meshes at runtime with this plugin: https://www.unrealengine.com/marketplace/runtime-mesh-component
Note however that you lose a lot of extra goodies and optimizations with that approach.
I want to make a main Gameobject in Unity3D that would act as a command center for anything related to controls so that any component in the game that needs to know if the player is trying to go right would get a notification or a state change and act accordingly. I am kind of new to programming and scripting in Unity, so I know this is possible, but I don't know how to do it specifically with the engine.
A few concepts I came across are:
state changing techniques
Singleton God classes
Parent GameObject with children that send messages upwards and receive them downwards
Inheritance of abstract classes that act as interfaces and get implemented into some collection and iterated through to get the message called on
If you guys have any insights on this subject that would be great. I basically want to find out what's a good approach for this problem, how to decide on a good one (Pros vs. Cons) or if I got it all wrong. :)
All I am looking for is an implementation example of your method of choice that worked for this purpose. No need to go into each separate method. Maybe a brief description of why you decided on your pattern would be great!
Thanks in advance!
Well, you may use a C# events:
1) Create your CommandCenter class (MonoBehaviour), implement there some events you need to share, and make some public methods to call tham.
2) whenever you handle a button player press, call the method in CommandCenter, that calls an event (or, you may just make events public and call tham directly)
3) In each component, witch should know about some event, in Awake method, do the following:
var commandCenter = FindObjectOfType(CommandCenter);
commandCenter.MyEvent += localMyEventHandler;
4) don't forget to unsubscribe for events on destroy:
OnDestroy ()
{
var commandCenter = FindObjectOfType(CommandCenter);
commandCenter.MyEvent -= localMyEventHandler;
}
5) So, in localMyEventHandler method you can handle this event.
First of all: Happy new year!
I have a problem with Flash CS5.5, AS3. I have two ScrollPane Components in my document. They are both in another scene and the (instant)names are unique. But it isn’t working properly. When I go to the other scene with the second ScrollPane I get an error & it starts to flicker.
My error:
TypeError: Error #1006: setSize is not a function. at
application051_fla::MainTimeline/frame25()[application051_fla.MainTimeline::frame25:7]
I want to make an iPhone application and I want that multiple components working properly in one document.
My little piece of code (don’t think that the problem is in here):
ScrollPane02.source = tekst03;
ScrollPane02.setSize(350,400);
ScrollPane02.move(0, 20);
ScrollPane02.scrollDrag = false;
If you know the answer or what I am doing wrong, please comment! Searching for hours/days!
Thanks in advance!
Uploaded the .fla document. If you want to take a look at it (please), you can download it here: http://www.bregjebouwmans.nl/application061.fla
Edit:
Ok, after digging through the FLA, I finally figured out what you did . . . you right clicked on ScrollPane in the "Library", and clicked "Duplicate". Then you gave it the name ScrollPane02. Except that the duplication process did not connect the new object to the ScrollPane's setup. Instead, it created a generic MovieClip object. Since it is not an actual ScrollPane, it makes sense that all the methods on the timeline's Actionscript will fail.
This is why the solution (in the comments below) works. #AsTheWormTurns just used the first (actual) ScrollPane in two instances on the timeline; is a viable solution.
(The only caveat being that if you change the ScrollPane object in the Library, it will affect all instances. That shouldn't really be a problem, since -- for components -- you generally make changes only to instances.)
Useful tips from my initial answer:
When compiled into an SWF, scenes are just stuck one right after the other in the timeline, just like scenes in a movie. If you do not have a stop() at the end of one scene, it will continue to run right into the next scene, just like a movie. The idea of scenes is to separate content. This means that what exists in sceneA does not exist in sceneB. The scenes also have no access to each other.
My advice is to not use scenes at all. They are difficult to use correctly, and have very little use that is not better done using the timeline or Actionscript.
I want to make a little in-app demo like Tapbots does in Convertbot. Maybe there is a better solution than mine?
make everything programmatically controlable
write a huge class with hundreds of performSelector:withObject:afterDelay: calls to control the whole app for the demo
The demo actually only does two things:
Simulate touches on controls (i.e. programmatically pressing buttons)
Show text message bubbles when appropriate to explain what is going on
How would you do it?
I don't think there is an easy way to accomplish this.
My suggestion would be to create a class that runs a script of actions for you. The script itself could be as simple as an NSArray of objects representing steps in the demo, each with values such as text for a callout bubble, an action/target pairing (for calling selectors), delay, and so forth. Use NSButton setHighlighted: to simulate button presses. Your class then runs through the array of steps to conduct the demo. You could code this directly, or construct the script at runtime from a YAML file (or other file format that you find easy to edit).
I would expect that investing some time in a mechanism like this will make your life a lot easier when it comes time to a) write and b) fine tune your demo, particularly down the road when you want to add features. You don't want to be managing a huge list of hardcoded calls. And you might even be able to re-use the demo-running code on other projects.