Author Topic: RegalPrime-UnityEngine v1.4.1 - 8-18-15  (Read 31053 times)

RegalPrime

  • Wannabe
  • Posts: 37
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 44.0.2403.155 Chrome 44.0.2403.155
    • View Profile
  • Playstyle: Keyboard
Working on something a few days ago and I noticed I had a main prefab messed up.

The prefab 'Entire Room Setup', 'Entire Room Setup - Alt', and 'PlayerSpawnController' have the wrong guy prefab attached to it (GuyCharacterPrefab_Physics_aTEST). This means a test version of the guy prefab will spawn unless you change it to the 'GuyCharacterPrefab_Physics_Prechecks' prefab or the 'GuyCharacterPrefab_Pixel' version.
- In short, the prefab would spawn the wrong guy unless you changed it yourself.

https://www.mediafire.com/download/kj9lknrls7pl86w/RegalPrime+-+UnityEngine+v1.4.1.zip
- Spawns the 'GuyCharacterPrefab_Physics_Prechecks' guy as the default

I thought it was important enough to change this and re-release the engine. If you know what is going on in the engine you can just change the prefab yourself and not re-download it.

Overall I have been a bit lazy on doing stuff for this engine since the last release mostly because I hit a wall on what I should do. Finally figured I would work on dealing with larger based maps (multi-screens) and see where that will take me. Possible hub based maps as well.

ace11575x

  • Wannabe
  • Posts: 3
  • Looking forward to streaming IWannas!
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 46.0.2490.86 Chrome 46.0.2490.86
    • View Profile
    • Twitch Stream
Been having an issue with the guy " falling" on the last pixel of the box collider. I tried fixing this by tweaking the Colliderindent but this breaks more things than it fixes. got any ideas? image attached.

RegalPrime

  • Wannabe
  • Posts: 37
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Been kinda away from the engine for a while doing other things but I will try to give you some insight.

When I was building this part, sadly there is no easy way to calculate "what is ground / wall / ceiling" easily.
Min penetration for penalty (MPP) is how fat the colliders are. Remember this is for every collider in the game. So if you had a MPP of 1 pixel (0.01), then two object's colliders are touching if they are 2 pixels apart (even 2 colliders right next to each other are still considered touching). In order for something to be NEXT TO but not touching, you need to be 2.00001 pixels part for the objects in this case.

Imagine a box 32x32 pixels. "Behind" this box is a 32x32 pixel "deadly object." I need to be sure the guy can stand on the box without being instantly killed by the deadly object of the same size.


Here are the ingame settings for the guy.
To translate the below numbers into pixels you x100

Min penetration for penalty (MPP) - Is set in the physics 2d menu

ColliderBuffer - Is set in the actual script for the guy. Either "PlatformerCharacter2D_Pixel" or "PlatformerCharacter2D_Physics_Prechecks" at the top of the script. It will look something like.
"private float ColliderBuffer   = 0.011f;   // Closest distance you can get between two colliders"

The ColliderBuffer is used in the scripts to deal with when the character gets close to a solid object in order for him to move the correct shortened distance to that solid object (ie you dont want to move at the full speed when you are REALLY close to a solid object). In the example of the box and deadly object, there were times walking across such an example was fine, but when you jump and landed, the character would die due to physics, very slightly, clipping him into the deadly zone (this is how physics works and what the MPP buffer is used for).

Physics Version - "PlatformerCharacter2D_Physics_Prechecks"
Min penetration for penalty - 0.004f
ColliderBuffer - 0.011f

So, why the MPP value of 0.004f ?? Physics based movements need at least some buffer in order to calculate their physics stuff. This is the lowest tested value I was able to put it without odd things happening. So the buffer we need would be 0.004 * 2 + 0.001 = 0.009f.  If you want you could change the collider buffer to that value to lessen the chance of clipping. Why the value of 0.011f, I really dont remember, but I figured it was the best after testing and I left it at that. This was tested a few Unity versions ago so you never know how things might have changed. Remember that 0.01f is actually one pixel (quite the buffer) between objects.

Feel free to mess with both the MPP and Collider buffer values (always remember what the default values are though). Also, watch what happens when you lower the MPP near 0 (the physics version will start acting odd at times). Always make sure the ColliderBuffer is at least 2xMPP + 0.0001 though.


Pixel Version - "PlatformerCharacter2D_Pixel"
Min penetration for penalty -  0.0001f
ColliderBuffer - 0.0004f

0.0001f * 2 + 0.0001 = 0.0003f  (I used 0.0004 but the difference is almost nothing)
After all the explanation above you can see the pixel values are extremely small comparatively. "Physics" in this version are calculated via transforms in the script and not by Unity thus I have more control. Things are a bit more stable using this version.

You can always use the Pixel guy version for better accuracy and stability, but you will lose the ability to climb slopes. All you have to do is add the pixel version to the spawner and set the correct MPP (I believe it warns you in the editor if you didnt change the MPP value.


Finally there is one more value you can mess with in "CalculateChecks.cs"
This script deals with checking distance to solid objects (wall / ceiling / ground) and is used by any other script that needs it (even the AI).
"private float ColliderIndent = 0.009f;      // The slight indent of AoE checks to prevent false positives (if needed)"

This was put into the script many Unity versions ago just in case something I needed it (this was previous to being able to change the MPP). As you can see from the comment it deals with false positives. To tell you the truth, I dont know what the "correct" value for this should even be. I am not even sure anymore what making it 0 would do. Feel free to change it to see how it effects things (values between 0.000f - 0.050f).

These are the top few things that you can mess with that would help deal with this issue.
Hopefully you understand what certain values are and how they effect the engine.

Sorry for the late reply.
« Last Edit: January 01, 2016, 01:47:40 AM by RegalPrime »

radicalero

  • Wannabe
  • Posts: 10
  • OS:
  • Windows 8/Server 2012 Windows 8/Server 2012
  • Browser:
  • Firefox 43.0 Firefox 43.0
    • View Profile
  • Playstyle: Keyboard
Re: RegalPrime-UnityEngine v1.4.1 - 8-18-15
« Reply #63 on: January 01, 2016, 11:04:59 AM »
Hi! When you calculate get next update?