Bullet World.Step causes 0xC000001D: Illegal Instruction (C# BulletSharp) - c#

So i am using BulletSharp in my project.
This is the code i use to step it:
if ((float)simTime.Elapsed.TotalSeconds < time)
{
time = 0;
timeStep = 0;
}
timeStep = ((float)simTime.Elapsed.TotalSeconds - time);
time = (float)simTime.Elapsed.TotalSeconds;
world.StepSimulation(timeStep, 7);
Everything works fine as long as i only add BoxShapes, but as soon as i add a ConvexHullShape it starts crashing.
It just crashes and shows world.StepSimulation as the error line, with error "0xC000001D: Illegal Instruction".
I Tried:
Only Adding Box Colliders (Works but ConvexHullShapes dont)
I wasnt able to reproduce it with any __asm code run in bullet

Related

Unity Multiplayer Position Interpolation results in coordinites being infinity

I am working on a multiplayer FPS using Tom Weiland's Riptide networking solution. I followed his three part tutorial on setting up basic networking and movement, but ran into an error after implementing interpolation (This video).
When only one player is connected to the server it works fine, but when two players are connected the following error occurs (client side):
transform.position assign attempt for 'Player 2 (editor)' is not valid. Input position is { Infinity, Infinity, -Infinity }.
UnityEngine.Transform:set_position (UnityEngine.Vector3)
Interpolator:InterpolatePosition (single) (at Assets/Scripts/Interpolator.cs:56)
Interpolator:Update () (at Assets/Scripts/Interpolator.cs:43)
The Update and InterpolatePosition functions in which the error occurs are:
private void Update()
{
for (int i = 0; i < futureTransformUpdates.Count; i++)
{
if (NetworkManager.Singleton.ServerTick >= futureTransformUpdates[i].Tick)
{
previous = to;
to = futureTransformUpdates[i];
from = new TransformUpdate(NetworkManager.Singleton.InterpolationTick, transform.position);
futureTransformUpdates.RemoveAt(i);
i--;
timeElapsed = 0f;
timeToReachTarget = (to.Tick - from.Tick) * Time.fixedDeltaTime;
}
}
timeElapsed += Time.deltaTime;
InterpolatePosition(timeElapsed / timeToReachTarget); // Line 43
}
private void InterpolatePosition(float lerpAmount)
{
if ((to.Position - previous.Position).sqrMagnitude < squareMovementThreshold)
{
if (to.Position != from.Position)
transform.position = Vector3.Lerp(from.Position, to.Position, lerpAmount);
return;
}
transform.position = Vector3.LerpUnclamped(from.Position, to.Position, lerpAmount); // Line 56
}
I have double checked and this is how it appears in the tutorial. I haven't used Lerp or LerpUnclamped before, and don't really know how to diagnose the issue. The error results in very choppy movement, often with several seconds between position updates, and no smoothing between them, making the game unplayable.
I am running the server and one client in the Unity editor, and the other client as a build, all on one computer. It doesn't matter which order I connect the clients in, both experience the issue when both are connected.

I want to activate a same animation for few different objects trough FOR loop. Animation don't sync and go in random intervals. Here is the code:

So, firstly, my scene is made out of 9 empty objects each one having spikes that have animation to pop out of the floor. I am making a game where you should avoid spikes and other projectiles. I tested this first with sprite renderer and changing colors, it worked perfectly. But when I want to activate animations using trigger (animations start from empty game state and go to their animations, then after it finishes they return to normal). I've looked trough every thing I could think of and I could not solve this. It always starts animations for 4-6 different animations and start them at the same time, but for some reason: AFTER FIRST SHOWING, every single time after first time spikes appear, 2/3 out of 4/6 always show late but start at same time. Weirdly first time it always works greatly. Any thoughts on what may cause this?
void Update()
{
if (spikeTimer > 0)
spikeTimer -= Time.deltaTime;
if (spikeTimer<0)
{
Function();
spikeTimer = spikeCooldown;
}
}
public void Function()
{
int x = Random.Range(4, 6);
List<int> included = new List<int>();
while (included.Count < x)
{
int y = Random.Range(1, 10);
if (!included.Contains(y))
{
included.Add(y);
}
}
foreach (int i in included)
{
print("aktiviran je broj" + i);
Spikes[i - 1].GetComponent<Spike>().ActivateSpike();
}
}
Now this is the ActivateSpike method that all Spikes in the scene contain
public void ActivateSpike()
{
SpriteRenderer sr = gameObject.GetComponent<SpriteRenderer>();
if (sr.color != Color.black)
{
sr.color = Color.black;
}
else
sr.color = Color.red;
/* Animator animator = gameObject.GetComponent<Animator>();
animator.SetTrigger("Activate");*/
}
You can see that I tried changing the sprite to square and changing its color, and it works perfectly...

MOGRE 1.8.1 + WPF (C#) - Back Buffer is not valid when user changes resolution or computer goes to sleep

I'm working with MOGRE 1.8.1 to embed 3D models within a WPF application. I've run into an issue where the application crashes when the user changes resolution or their computer goes to sleep. I believe this is because the render system is trying to draw to a surface that it doesn't have access to anymore.
I'm not exactly sure what to do; I've tried using the dispose method to kill MOGRE and reboot it later (by catching the windows event), but have run into a memory leak. The pause render method included within the MOGRE library does not seem to work either. Does anyone have any ideas on how to circumvent this issue?
Notes
You can find the example I'm running here. Main difference is that I'm using the 1.8.1 .dlls instead -> http://www.codeproject.com/Articles/29190/Blend-the-OGRE-Graphics-Engine-into-your-WPF-proje , but the error is present in both.
OgreImage.cs is where the issues are happening.
Thank you for your help.
This error happen when the device is lost, so you have to add your control in the function RenderFrame()
//WallPaper, CTRL + ALT + DEL, etc
if (this.isDeviceLost)
{
//Recreate the texture render
ReInitRenderTarget();
//Restore device lost
_renderWindow._beginUpdate();
_renderWindow._endUpdate();
_reloadRenderTargetTime = -1;
this.isDeviceLost = false;
}
And this is my ReInitRenderTarget() function
protected void ReInitRenderTarget()
{
DetachRenderTarget(true, false);
DisposeRenderTarget();
_texture = TextureManager.Singleton.CreateManual(
"OgreImageSource RenderTarget",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
TextureType.TEX_TYPE_2D,
(uint)ViewportSize.Width, (uint)ViewportSize.Height,
0, Mogre.PixelFormat.PF_R8G8B8A8,
(int)TextureUsage.TU_RENDERTARGET);//, null, false, 8);
_renTarget = _texture.GetBuffer().GetRenderTarget();
_reloadRenderTargetTime = 0;
int viewportCount = ViewportDefinitions.Length;
viewports = new Viewport[viewportCount];
for (int i = 0; i < viewportCount; i++)
{
Viewport viewport;
ViewportDefinition vd = ViewportDefinitions[i];
viewport = _renTarget.AddViewport(vd.Camera, zIndexCounter++, vd.Left, vd.Top, vd.Width, vd.Height);
viewport.BackgroundColour = vd.BackgroundColour;
viewports[i] = viewport;
}
var ev = ViewportsChanged;
if (ev != null) ev();
viewportDefinitionsChanged = false;
}

Coroutine only firing once

I'm trying to run a script that will generate a "ramps" upon touch between point a and b. This code receives a list of where the elements of the ramps should be and then instanciates and places them on the screen.
However the coroutine is only running once and I can't understand why. Can anyone give me some advice?
Thank you very much in advance
public IEnumerator CreateRamp(List<Vector3> lP, float angle)
{
int i = 1;
while (i <= lP.Count)
{
Debug.Log("Iteration " + i + " of " + lP.Count + " position is " + lP[i]);
GameObject item = Instantiate(Resources.Load("floor")) as GameObject;
item.transform.position = current_Position;
item.transform.eulerAngles = new Vector3(0, 0, UnityEngine.Random.Range(0f, 360f));
item.GetComponent<Ramp>().strtPos = item.transform.position;
item.GetComponent<Ramp>().strtRot = item.transform.eulerAngles;
item.GetComponent<Ramp>().strtScale = new Vector3(0.4f, 0.4f, 1);
item.GetComponent<Ramp>().tgtRot = new Vector3(0, 0, angle);
item.GetComponent<Ramp>().tgtPos = lP[i-1];
i += 1;
yield return new WaitForSeconds(0.2f);
}
}
I suspect your condition i <= lP.Count is true only once. (Maybe lP.Count == 1, I think).
The way co-routine works is that, the code inside the CreateRamp function is executed across multiple frames.
When you StartCoroutine(CreateRamp(...)), it is immediately run until it hits yield statement. It will wait there for 0.2 seconds and will be run again from the statement right after the yield.
In the second execution, it evaluates the condition i <= lP.Count again and see that it is False => it jumps out of the loop and because it hits the end of the function, that co-routine will be stopped, no more execution in the future.
Since this function is an IEnumerable it should be treated by other code as a list of Ramp objects. I suspect (there isn't enough of your code to know), that the way you are calling this function is incorrect.
On a side note, with your yield returning a waitforX, It would be better in the long term to either perform the wait outside of this function (where you are calling it from) or at the very least add the wait period as a parameter to the function. Hard coded values like that will end up biting you later on, especially if your game's code-base grows. I recommend it be exposed as a setting on your GameObject, so it can be tweaked from the editor.
One other thing, How do you destroy these Ramp objects when you are done with them? It might be good to consider storing references to them as you create them so you can destroy them later.

Programming issue. Lag

Ive been having some issues programming in unity with c#. I am trying to request an interstitial AD when i start the game so i can show it when the player has died 5 times. The issue is that when i get to the 5th death the ad won't show. and when I try requesting the ad when the level starts it gets laggy and still doesn't show.
This is my code. It seems right.
void Update(){
if (clicks >= 5) {
RequestInterstitial();
Debug.Log("Got 5 clicks");
if (interstitial.IsLoaded()){
Debug.Log("interstitial loaded");
interstitial.Show();
clicks = 0;
}
}
}
EDIT: After modifying my code, I now get the error:
NullReferenceException: Object reference not set to an instance of an object ADS.ADMobsGameplay.Update () (at Assets/Scripts/ADS/ADMobsGameplay.cs:28)
Line 28 corresponds to if (interstitial.IsLoaded()){ in the following code:
void Update(){
if (clicks >= 5) {
Debug.Log("Got 5 clicks");
if (interstitial.IsLoaded()){
Debug.Log("interstitial loaded");
interstitial.Show();
clicks = 0;
}else{
RequestInterstitial();
}
}
}
You are Requesting the Interstitial over and over again. Just run the RequestInterstitial method at the beginning of the program (and make sure it only runs the method once).
Then, in whatever method you increment clicks, simply add something like this to the end:
int clicksRequired = 5;
int currentClicksRequired = 5;
if(clicks > currentClicksRequired){
Debug.Log("Got 5 Clicks");
if (interstitial.IsLoaded()){
Debug.Log("interstitial loaded");
interstitial.Show();
RequestInterstitial();
clicks = 0;
currentClicksRequired = clicksRequired;
}else{
Debug.Log("interstitial not loaded, skipping to next click");
currentClickRequired ++;
}
}
Once clicks reaches 5, it will check if the interstitial has been loaded. If so, it shows the interstitial, requests another interstitial, resets clicks at 0, and then moves on. If the interstitial is not loaded yet, it makes you wait till the 6th click, or the 7th, etc, until the interstitial is loaded.
First of all, you shown NullReferenceException error in yours comment: this is first issue that can provide lags. Second - it is really weird to put some counting logic into Update function - update works every frame - so it`s second possible lag issue. Third Debug.Log function is not a lightweight, into Update function it will be third possible lag issue

Categories