• 10
• 10
• 12
• 12
• 14
• ### Similar Content

• By bowcox
Hi guys!
I have created a Pong game that has an AI that is almost beatable, changing the speed of the AI can make it ridiculously easy or hard depending on the way you go about it.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class ComputerMovement : MonoBehaviour { private float speed; private float reAdjustSpeed = 1f; private Rigidbody2D computer2d; public static bool isTwoPlayer; GameObject theBall; Rigidbody2D rb2d; void Start() { computer2d = GetComponent<Rigidbody2D> (); } void FixedUpdate() { if (isTwoPlayer == true) { speed = 5f; if (Input.GetKey (KeyCode.W)) { computer2d.position += Vector2.up * speed * Time.deltaTime; } if (Input.GetKey (KeyCode.S)) { computer2d.position += Vector2.down * speed * Time.deltaTime; } } if (isTwoPlayer == false) { speed = 3f; if (theBall == null) { theBall = GameObject.FindGameObjectWithTag ("Ball"); } rb2d = theBall.GetComponent<Rigidbody2D> (); //Is the ball going left or right if (rb2d.velocity.x > 0) { if (rb2d.velocity.y > 0) { if (rb2d.position.y > computer2d.position.y) { MoveUp (); } if (rb2d.position.y < computer2d.position.y) { MoveDown (); } } if (rb2d.velocity.y < 0) { if (rb2d.position.y > computer2d.position.y) { MoveUp (); } if (rb2d.position.y < computer2d.position.y) { MoveDown (); } } } //Whilst it's not moving at the paddle, let it gain a slight reset by moving with the ball at a slower pace. if (rb2d.velocity.x < 0) { if (computer2d.position.y < 0) { computer2d.position += Vector2.up * reAdjustSpeed * Time.deltaTime; } if (computer2d.position.y > 0) { computer2d.position += Vector2.down * reAdjustSpeed * Time.deltaTime; } } } } void MoveDown() { if (Mathf.Abs(rb2d.velocity.y) > speed) { computer2d.position += Vector2.down * speed * Time.deltaTime; } else { computer2d.position += Vector2.down * speed * Time.deltaTime; } } void MoveUp() { if (Mathf.Abs (rb2d.velocity.y) > speed) { computer2d.position += Vector2.up * speed * Time.deltaTime; } else { computer2d.position += Vector2.up * speed * Time.deltaTime; } } }
I have looked up several posts across many different forums in order to create a much better AI. Most of the posts recommend that I use Raycasts to find out exactly where the ball might hit the paddle. I have looked up how to use them and I'm just completely lost, do raycasts consider collisions and go on infinitely or once they hit a wall, that's where it'll end up? Would anyone be able to help me understand raycasts a little better?
If you have another solution that enables me to calculate exactly where the ball will end up on the opponents side, I am more than willing to hear it
Thanks again if you read this!

• We're looking for a Unity (C#) Programmer for our 2D Project. We're looking for a new lead programmer to continue with an existing project.

Project is an open-world RTS, and is very close to a prototyping (playable) phase. Our existing lead, unfortunately, has no more time for the project, and thus we are in search of a new one who is interested.

Game is purely fantasy based, and we'll be able to give you much more detailed info about the project as we begin to work you into it.

You'll be working with our junior developer, who has been here since the beginning.

Primary skills needed are just being able to work within Unity. But skills within XML are also a plus.

Our list of major goals we'd need you to do is minimal, yet still fairly extensive:
-Edit our current Pathfinding system to account for a few extra features.
-Setup our global map system. You’ll be working off an existing random node-map web generator and existing random map generation system and essentially linking the two together. This includes handling random spawns (which has already been semi-setup) unique to each node’s respective map.
-Further implementation of an existing random spawning algorithm (used to spawn things like enemies randomly across the Map).
-Making sure to Save and Record all respective aspects of what was mentioned above.
-Handling our XML database- database is created, but we’ll need to be integrating it. This includes all various things from units to abilities and so forth. Will also need to handle implementing an object’s unique attributes we cannot take care of within XML.
-Various Content Implementation (to be done once our XML has been integrated).
-Various Saving and Recording of all respective aspects of the database info mentioned above.
-Various Performance Enhancements.
-Potential for various misc things, such as further UI work.

We have a considerable amount of things done already- however I must warn ahead of time we have quite a bit of unclean code, which may be fairly overwhelming for a new developer on the project.

Let me know your rates per hour, and we'll see if we can work out a good deal between both of us. Royalties are also included.

If interested, send an email to: eldwin11929@yahoo.com

Thanks!
• By jhocking
My bestselling and highly recommended Unity book has been fully revised! Unity in Action, Second Edition teaches you to write and deploy games with the Unity game development platform. You'll master the Unity toolset from the ground up, adding the skills you need to go from application coder to game developer.

Foreword by Jesse Schell, author of The Art of Game Design

Don't take my word for it being good, look at the sky-high ratings on GoodReads.

You can order the ebook directly from the publisher's site, or order the book on Amazon to get both the physical book and a coupon to download the ebook!

• Hello everyone, I am working on a game idea and since I am still in the process of learning C# and the features available in unity I was hoping some of you might be able to offer me a little insight on things in general for getting started.
I guess the basic components of what I'm wanting to create would be a Multi-levels management/city builder/rpg.
The goal is to provide a framework for players to interact with, build in and affect the world both from a 3rd person action RPG as well as a zoomed out 4x style view (This would be something unlocked through gameplay)

As for my questions go I was wondering if anyone had resources that could help me learn.  I've been on youtube as well as enrolled in an online course for basic unity and C# and will continue those but if anyone has any words of advice, a place that has good information and tutorials etc.

•
Hi, I'm new in this forum. It is honorable to see such communities exist. I would like to share my new game. I did for android with unity. I know the game is a little awkward , but you have to know that this game is from the time when Unity's name is Unity3D  I have made my first game when I was 12. Now I am 22.  I have taken a lot of experience in this process and I can make better games nowadays. I have published this game nowadays but actually this game is very old but also it is very special for me :))
I have just wanted to retouch and share this game, because it has a very important place for me.

It's a special free 3D horror adventure action game for the halloween. Fun with scary sound effects and musics, 3D realistic graphics, you will feel the horror in the deep of your heart. Use your reflex. Totally free adventure. Totally scary horror game.

Tamarra, she is a beast from our world. She needs to consume souls from innocent people to stay alive. Story begins, the old Elaris tribe had lost their everything because of this beast who lived in the well. Araknas was the most powerful warrior of the tribe. One day, Araknas's mother was killed by the servant beasts of Tamarra. That's how Araknas's journey to the well begins. Tamara's well is guarded by horrible beasts. Araknas has to pass all servant beasts until he reaches Tamarra.

Even death at the end is worth the revenge.
Are you brave enough to jump into Tamarra's well?

Survive from witch attacks, clown attacks and many scary creature.

- Realistic 3D graphics.
- Scary sounds.
- Scary musics.
- A demon cage where you can imprison all the demons one by one
- The witches do not like help, but they love blood stone. Witch store where you can develop your abilities and get new abilities.
- Countless beasts.
- At the end of the well there is a hidden surprise for you.

*We do not recommend this game to people with clown phobia, spider phobia, or panic attacks.*

**!!!**Note : This game is an early-access game, we are upgrading new features every day, new beasts, new improvements, as an example online 1vs1 fall on the list, so stay on connect and follow Halloween : Horror Well on Google Play.**!!!**

# Unity Port XNA to iOS step-by-step (using MonoGame)

This topic is 1834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey everyone,

So I have an XNA 4.0 windows game in VS2010 running on my Windows PC (windows 7).

The game itself isn't finished yet, but before I continue work on it I'd like to try to get it running on my iPad, so that I suss out the porting procedure and feel confident about continuing to use XNA. The primary platforms I'd like this game to go on would be on Windows (and possibly Mac) and iOS.

I know that monogame is the way to go with porting XNA to iOS, but I'm finding it difficult finding step by step walkthroughs as to how to actually do this.

This is what I currently have:

A windows 7 PC

Visual Studio 2010

My XNA 4.0 game project on windows 7

A Macbook

MonoDevelop (it was installed as part of the Unity 4.0 install)

An iOS developer account

Latest XCode

Can anyone point me to any tutorials or guides as to how I can, from here, get my game ported over to iOS? Any comprehensive help and tips along with them would be much appreciated.

Thanks so much.

##### Share on other sites

Well... now time for the bad news...

You also need a copy of Xamarin for iOS ( previously known as MonoTouch ).

Now for the worser bad news...

Actually, no longer! If you use their brand-new Xamarin Studio package, you can release to Android, iOS, and Mac OS X for free. The free version is really only usable for smaller apps that don't require P/Invoke (its not supported) and the version that does support P/Invoke is $299 (for everything). Its not perfect, but its a good starting point. As far as XNA to MonoGame is concern, it should be pretty straight forward if you are only of Windows. When you get into Mac and Linux it does become slightly more complicated. I've never really worked with XNA or MonoGame, but people who I know have (and made the switch) say it isn't had to move. Still, my first move would be to switch from XNA to MonoGame in Windows first and then switch from Windows to Mac OS X or Linux. #### Share this post ##### Link to post ##### Share on other sites Well... now time for the bad news... You also need a copy of Xamarin for iOS ( previously known as MonoTouch ). Now for the worser bad news... It has a 299$ price tag.  There is however a 30 day full functioning trial I believe.

Actually, no longer! If you use their brand-new Xamarin Studio package, you can release to Android, iOS, and Mac OS X for free. The free version is really only usable for smaller apps that don't require P/Invoke (its not supported) and the version that does support P/Invoke is \$299 (for everything). Its not perfect, but its a good starting point.

As far as XNA to MonoGame is concern, it should be pretty straight forward if you are only of Windows. When you get into Mac and Linux it does become slightly more complicated. I've never really worked with XNA or MonoGame, but people who I know have (and made the switch) say it isn't had to move. Still, my first move would be to switch from XNA to MonoGame in Windows first and then switch from Windows to Mac OS X or Linux.

The pInvoke limitation is worse than you think...  Your code may not require pInvoke, but MonoGame does ( that's how it calls to OpenGL ).  I may be wrong, but im 90% certain the "free" version doesn't work with MonoGame.

##### Share on other sites

The pInvoke limitation is worse than you think...  Your code may not require pInvoke, but MonoGame does ( that's how it calls to OpenGL ).  I may be wrong, but im 90% certain the "free" version doesn't work with MonoGame.

Well MonoGame uses OpenTK for the OpenGL/ES backends. I checked the source code and it uses System.Runtime.InteropServices not DllImport or any of the other P/Invoke methods (although I don't know what InteropServices does in the backend).

EDIT: Information in this post is completely wrong and invalid.

Edited by Josh Vega

##### Share on other sites

Well MonoGame uses OpenTK for the OpenGL/ES backends. I checked the source code and it uses System.Runtime.InteropServices not DllImport or any of the other P/Invoke methods (although I don't know what InteropServices does in the backend).

I think you misunderstand what p/invoke means.

p/invoke is a shorthand for saying it uses InteropServices to perform automatic marshalling to and from the platform's libraries rather than using the .net method.

The source code you linked to has about 600 lines of this:

[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glDrawArrays", ExactSpelling = true)]
internal extern static void DrawArrays(OpenTK.Graphics.ES20.BeginMode mode, Int32 first, Int32 count);
[System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(GL.Library, EntryPoint = "glDrawElements", ExactSpelling = true)]
internal extern static void DrawElements(OpenTK.Graphics.ES20.BeginMode mode, Int32 count, OpenTK.Graphics.ES20.DrawElementsType type, IntPtr indices);



That is a textbook example of p/invoke.

You wrote it does not use DllImport, but every single one of those entries is marked as DllImport.  Every single function is marked with "System.Runtime.InteropServices.DllImport".

That is what Serapth was pointing out.  It uses p/invoke all over the place, which your source code link confirmed rather than denied.

This is one reason I personally dislike the "free" libraries that have requirements of paid libraries.  They are generally less free than they advertise.

Edited by frob

##### Share on other sites

Woah!

I don't even know how I missed that. I know that from prior experience that InteropServices is a P/Invoke method. I must have have gotten the question confused with another C# question I was emailed by a friend. Its been a busy day for me.

##### Share on other sites

@SeraPath and @Josh Vega: The MonoGame team is working with Xamarin, to have their assemblies white listed, so they can be used with the Free version.

No ETA yet, but it is coming.

@dechorus, I would suggest posting any questions you have in the monogame.codeplex.com discussion forums.

D.

##### Share on other sites

@SeraPath and @Josh Vega: The MonoGame team is working with Xamarin, to have their assemblies white listed, so they can be used with the Free version.

No ETA yet, but it is coming.

Now that is an excellent news ! Do I understand it correctly that when these assemblies are whitelisted, one will be able to use the free version of Xamarin, then ?

To be more specific, if I am not using any other assemblies (other than .NET and XNA), I read it that I actually am not doing any other PInvoke, correct ?

Or will only XNA replacements will be whitelisted, but not the .NET ones [for the free version] ?