Hi everybody, I am trying to compare colors in IJobParallelFor but there is no match all counters equals 0
I am new at Job System so what ı am missing ?
[BurstCompile]
public struct PaintColorCalculationJob : IJobParallelFor
{
[NativeDisableParallelForRestriction]
public NativeArray pixelColors ;
[NativeDisableParallelForRestriction]
public NativeArray playerColors ;
public NativeArray playerScores ;
public int numberOfPlayers ;
private bool isPlayerColor ;
public void Execute(int index)
{
for (int y = 0; y < numberOfPlayers; y++)
{
if (( (pixelColors[index].r * 1000) <= (playerColors[y].r * 1000 + 100)&& (pixelColors[index].r * 1000) >= (playerColors[y].r * 1000 - 100)))
{
if ( (pixelColors[index].g * 1000) <= (playerColors[y].g * 1000 + 100)&& (pixelColors[index].g * 1000) >= (playerColors[y].g * 1000 - 100))
{
if ( (pixelColors[index].b * 1000) <= (playerColors[y].b * 1000 + 100)&& (pixelColors[index].b * 1000) >= (playerColors[y].b * 1000 - 100))
playerScores[y] = playerScores[y] + 1 ;
}
}
}
}
}
,Hi everybody, I try to compare pixel colors of my ground texture and count it which one is match but all counters equals zero. ı am new at Job System so what ı am missing ?
[BurstCompile]
public struct PaintColorCalculationJob : IJobParallelFor
{
[NativeDisableParallelForRestriction]
public NativeArray pixelColors ;
[NativeDisableParallelForRestriction]
public NativeArray playerColors ;
public NativeArray playerScores ;
public int numberOfPlayers ;
private bool isPlayerColor ;
public void Execute(int index)
{
for (int y = 0; y < numberOfPlayers; y++)
{
if (( (pixelColors[index].r * 1000) <= (playerColors[y].r * 1000 + 100)&& (pixelColors[index].r * 1000) >= (playerColors[y].r * 1000 - 100)))
{
if ( (pixelColors[index].g * 1000) <= (playerColors[y].g * 1000 + 100)&& (pixelColors[index].g * 1000) >= (playerColors[y].g * 1000 - 100))
{
if ( (pixelColors[index].b * 1000) <= (playerColors[y].b * 1000 + 100)&& (pixelColors[index].b * 1000) >= (playerColors[y].b * 1000 - 100))
playerScores[y] = playerScores[y] + 1 ;
}
}
}
}
}
↧
Job System Colors dont match,Comparing colors in Execute(int index) IJobParallelFor ?
↧
I want to edit the Gradient in the ShaderGraph from the Inspector
![alt text][1]If a Gradient node is propertized on the ShaderGraph, it will not be displayed on the Inspector.
Please tell me if there is a way to display it on an Inspector.
[1]: /storage/temp/145042-test.png
↧
↧
How do i define BuildPlayerOptions.assetBundleManifestPath without a custom script?
Im trying to define the BuildPlayerOptions.assetBundleManifestPath to point to my built bundle manifest but the only way I've been able to do so is using a custom build script like so:
BuildPipeline.BuildPlayer(new BuildPlayerOptions
{
scenes = sceneNames,
locationPathName = @"C:\{project path}\Builds\Build.apk",
assetBundleManifestPath = @"C:\{project path}\AssetBundles\Android\Android.manifest",
target = BuildTarget.Android,
options = BuildOptions.AutoRunPlayer
});
Is it possible do define the assetBundleManifestPath in the normal build settings interface or is a custom build script the only way?
↧
Normal map issue (direction)
Hi, masters. I was create a Shader Graph shader in Unity 2019.2 with LWRP and i got an normal map issue:
![alt text][1]
As you can see the normal map on edges is in reversed direction.
This is how normal map looks like in ather programs:
![alt text][2]
I tried to swich API Graphic from DirectX to OpenGL, but nothing happened.
If you know how to fix this it will be super! Thanks.
[1]: /storage/temp/145045-nm-issue.jpg
[2]: /storage/temp/145046-nm-issue-02.jpg
↧
humanoid animation problem
hello~ I try to make an animation of humanoid model.
and I want to make my own movenment(animation) through 3d humanoid model.
but I am just a beginner in this animation parts.
so I have a lot of questions but I couldn't solve these problems through the google.
I need your hands.
so, anyway.. I imported a model in unity from asset store for free. and then I tried to change. I mean I changed mesh.
I thought that is one of easy ways to change model's appearance. and I tried to make animation clips. but It didn't move I expect to. so I gave up.
next step, I put the animation I downloaded before. but.. I don't know why.. when I push the play button, the character took a bending position(even go down throw the floor). I 'm reaally panic on this.. I dont know how to fix this kind of problems. If you know, please let me know what is the reason and how can I fix it!
↧
↧
Grabbing adjacent object references on a grid
Hi everyone. I started learning Unity early this year, and I am currently playing around with making 2D puzzle games. A couple of my projects incorporate a grid of sprite/image objects, and in my scripts I am trying to grab references to adjacent objects in the grid. The way I'm doing it right now is to put colliders on all the objects on the grid, and use overlap methods to grab the object reference from the collider at a given point. My question is, is there a better way to do it? Because using colliders this way seems inefficient to me.
↧
AddForce to RigidBody2D on the same frame as SetParent(null) causes small jitter
I've got a Rigidbody2D sprite that's a child of a rotating circle (the circle does not have a RigidBody2D). When I click the mouse in Update(), I unparent the sprite using SetParent(null) and apply an outward force using AddForce(force, ForceMode2D.Impulse) to the sprite.
----------
When I set the timescale low, I see the sprite jumps a short distance, then pauses for 5-10 frames, and then starts to move smoothly as expected. The short pause is not expected.
----------
When I simply remove the SetParent(null) call, I do not see this short pause. Unfortunately I can't use this as a practical solution as I do need to unparent the sprite.
----------
I've tried calling Physics2D.SyncTransforms() after unparenting, changing the interpolation type for my Rigidbody2D and adjusting Time.fixedTimestep but nothing changes. I also tried waiting a few frames to apply the force after unparenting, but it seems I need to WaitForEndOfFrame() 15-20 frames for this to remove the jitter.
----------
Does anyone know if it's "invalid" to unparent an object the same frame as trying to apply physics?
↧
Unity WebGL il2cpp.exe did not run properly
@ I don't speak English well so I hope you know that I use a translator I use Windows 10, Unity version 2018.2.8f1 I met the error "il2cpp.exe did not run properly" while building with WebGL I want to solve this I tried the following method
● I've modified the stack_size part from Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\emscripten.config to 1024 ● I deleted il2cpp_cache from the library inside the project file ● I modified the project file so that there was no language other than English and created a new folder inside the project file so that the build file could be created there.
I tried both methods above but the result was the same I suspected it might be a different problem So I installed Unity 2019 to create a new project and build a project without scripts and objects. Surprisingly the same error didn't build Build on another computer, reinstall Unity and try again I tried it, reinstalled Windows and tried and the error was the same I hardly know what to do If you know the answer please let me know
↧
Player glitching through wall when sprinting
Hello,
I have a 2d Game and a standard Player Controller for letting my player move.
**When I'm moving without pressing "Sprint" collisions work**, but when the players is **sprinting** it just runs through walls...My Walls are tilemaps with tilemap colliders and composite colliders (Even tried to turn them off to normal box colliders, but no difference). Hope you can help me. Thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovementPlayer : MonoBehaviour
{
public CharacterController charController;
public Vector2 direction;
private Vector3 change;
public bool sprint;
[SerializeField]
public float walkingSpeed;
public float runningSpeed;
void Start()
{
runningSpeed = walkingSpeed *1.5f;
}
// Update is called once per frame
void Update()
{
//Animation
change = Vector3.zero;
change.x = Input.GetAxis("Horizontal");
change.y = Input.GetAxis("Vertical");
charController.animate(change);
//Movement
if(change != Vector3.zero) { getDirection(); }
}
// FixedUpdate is called once per "time"
void FixedUpdate()
{
moveChar();
}
void moveChar()
{
if (sprint)
{
transform.Translate(direction * runningSpeed * Time.fixedDeltaTime);
}
else
{
transform.Translate(direction * walkingSpeed * Time.fixedDeltaTime);
}
}
void getDirection()
{
direction = Vector2.zero;
if (Input.GetKey(KeyCode.W))
{
direction += Vector2.up;
}
if (Input.GetKey(KeyCode.A))
{
direction += Vector2.left;
}
if (Input.GetKey(KeyCode.S))
{
direction += Vector2.down;
}
if (Input.GetKey(KeyCode.D))
{
direction += Vector2.right;
}
if (Input.GetKey(KeyCode.LeftShift))
{
sprint = true;
}
if (!Input.GetKey(KeyCode.LeftShift))
{
sprint = false;
}
}
}
↧
↧
Something Really Strange
Hey guys i am making a tps multiplayer game in unity.this is my first game in unity and overall
so the problem is really simple and weird. i put this piece of code in my ammo script:-
private void FixedUpdate()
{
if (ammoType=="RealTime")
{
transform.Translate(Vector3.forward * speed * Time.deltaTime);
if (Physics.Linecast(lastPosition, transform.position, out target,0,QueryTriggerInteraction.Ignore))
{
Debug.Log(target.transform.gameObject.name);
transform.position = target.point;
Instantiate(hitEffect, target.point, Quaternion.identity);
Debug.Log("Inst hit effect realtime");
Destroy(gameObject);
}
}
}
private void LateUpdate()
{
lastPosition = transform.position;
}
The purpose of this code is to avoid bullet through paper problem. So regardless of its speed projectile always knows when it collide with something. This code was working perfectly till yesterday, than suddenly it stopped working. im stuck with it and in all my life im unable to figure out what happened suddenly. any help regarding this would be greatly appreciated
↧
Updating a material color with both an animator and script
Hello,
I want to change the color of the same renderer material in two ways:
- Through script (depends on runtime data)
- With an animator (in the case I want to show an error, then my material blinks red)
The problem is that it works correctly, until I use the animator; then the material keeps the last color set by the animator, even if I try to update it through script (I debugged the script and it works as expected).
Here is a simplified version of my script:
public class TileColor : MonoBehaviour {
[SerializeField] protected MeshRenderer _renderer;
[SerializeField] protected Animator _animator;
public Color color { get; set; }
// I call this function to start the error-blinking animation, managed by the animator
public void BlinkError() {
_animator.enabled = true;
_animator.SetTrigger("Error");
}
// This function is called by an animation event when the animation ends
public void EndAnimation() {
_animator.enabled = false;
}
private void Update() {
if (_animator.enabled) return;
_renderer.material.color = color;
}
}
Anyone got an idea?
↧
Vuforia crashes when trying to augment animated objects after updating to Android 64bit
Hello,
I would like to ask if somebody has got any information regarding why Vuforia keeps crashing on Android when trying to augment an animated 3D object. The app gives no error log, it just closes. *This happens only when using IL2CPP*. I have never had thiss issue before. I have to use IL2CPP in order to meet the Google Play requirements. I have tried altering the Android Manifest, I have updated both Vuforia and Unity to the latest versions but this hasn't helped.
Thank you.
↧
rotate in the direction of the child
![alt text][1]
[1]: /storage/temp/145052-gshfshga.png
hi, i'm creating a FPS game and i want the character to wall run, but whenever i made it so the camera can turn freely around after wall running, but after the wallrun i been having some rotation problems, i want it so that after the wallrun, the body turns to the direction of the camera, but sense the camera is already the child, the camera turns with the body rotating to the camera, so does anyone know how to solve this?
↧
↧
IAP Product unavailable in Android Platform
I have already used Unity IAP package for my many games but today I started getting a problem with retrieving IAP product on actual Android device.
I have created a product and same ID, I have used within the PurchaseManager script. The game already releases in Alpha Test section to test In-App purchase implementation.
Within Unity Editor, I can able to retrieve one IAP product and able to make a purchase too but within Android device that same product is unavailable.
I have followed this tutorial and code for in-app purchase setup: [Tutorial Unity IAP][1] This kind of error messages, I am getting in the debug log: ![alt text][2]
![alt text][3] Now please share your side suggestions so I can move ahead for the game publishing. [1]: https://learn.unity.com/tutorial/unity-iap [2]: /storage/temp/145057-unity-iap-error1.png [3]: /storage/temp/145058-unity-iap-error.png
I have created a product and same ID, I have used within the PurchaseManager script. The game already releases in Alpha Test section to test In-App purchase implementation.
Within Unity Editor, I can able to retrieve one IAP product and able to make a purchase too but within Android device that same product is unavailable.
I have followed this tutorial and code for in-app purchase setup: [Tutorial Unity IAP][1] This kind of error messages, I am getting in the debug log: ![alt text][2]
![alt text][3] Now please share your side suggestions so I can move ahead for the game publishing. [1]: https://learn.unity.com/tutorial/unity-iap [2]: /storage/temp/145057-unity-iap-error1.png [3]: /storage/temp/145058-unity-iap-error.png
↧
Networking: Spawned objects are only visible on host (UNet/Mirror)
Im trying to create a first person bow game as multiplayer game with mirror. Mirror is pretty much unet.
For each player instance I am spawning a player prefab and a bow. On the host everything is fine, every player is holding a bow and I also can shoot arrows with the client, who is the host. On the other client every player instance has not a bow in their hands, but they were still spawned in the center of the map. Also the animator "bowAnimator" has not been set on this client. Every help is appreciated ;-)
This is the code I use for spawning the bow:
public override void OnStartLocalPlayer()
{
if (!isLocalPlayer)
{
return;
}
CmdInitializeBow();
}
[Command]
private void CmdInitializeBow()
{
bowFP = Instantiate(bowPrefab, Vector3.zero, Quaternion.identity);
bowFP.transform.parent = leftHandBone;
bowFP.transform.position = bowPlaceHolder.position;
bowFP.transform.rotation = bowPlaceHolder.rotation;
bowFP.transform.localScale = bowPlaceHolder.localScale;
bowAnimator = bowFP.GetComponent();
arrowSpawnPos = bowFP.transform.Find("Root");
NetworkServer.SpawnWithClientAuthority(bowFP, connectionToClient);
}
*BowPlaceHolder is the transform, where the bow is going to be. The reason why I am spawning the bow separately and not part of the player is, because it has to own network identity and network animator. Two network identities on the same GameObject, isnt working :/
↧
Problem with text size
Hi! I'm making an android app and it have a configuration screen. But the configuration screen's text doesn't change well with the "best fit" option. It gets only in the right size at the option "free aspect" without "maximize on play" , or "16:9". At ANY other resolution option, the text disappear or get bigger than the right size but with text "invading" the other's space and sometimes "break" the line. I tried adjust all the possible options in unity and search for some help in facebook groups, youtube, even unity3d website! The text usually adjust only the localization, and in bigger resolution gets text in only a small space or in a small space AND big size with the text line ""invading" other's space. The other parts of the app (aka the code) are already 100% done.
↧
How to make the 3D effect from 2 images?
Hi, I am making a game where two pictures: blue and red are moving away from each other to see how long one can see the 3D effect. My problem is that the sprites don't blend with each other and there's no 3D effect at all, instead one of them is overlapping the other one. I was trying to decrease the alpha variable, but stil one of the pictures is too dominant.
I guess that the answer is either to blend them or use some shader, but, as I've never worked with anything like this, it seems quite complicated.
Is there an easy way to blend the pictures? Or another simple way this could be done?
↧
↧
Disable jumping up a wall
How do i disable being able to jump up a wall without a Raycast?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
//Variables Initalization
public float Speed;
public float JumpPower;
public float RunningSpeed;
public float RunningJumpPower;
[HideInInspector]
public bool Grounded;
Transform Tf;
SpriteRenderer Sr;
void Start()
{
//Get Components
Tf = GetComponent();
Sr = GetComponent();
}
void FixedUpdate()
{
//Horizontal Movement
Movement();
//Vertical Movement
Jump();
}
void Movement()
{
//Get Axis
float X = Input.GetAxis("Horizontal");
//Move Player
if (Input.GetAxis("Run") > 0)
{
//Running Speed
Tf.Translate(new Vector2(X * RunningSpeed * Time.deltaTime, 0));
}
else
{
//Normal Speed
Tf.Translate(new Vector2(X * Speed * Time.deltaTime, 0));
}
Flip();
}
void Flip()
{
//Flip the Character when needed
if (Input.GetAxis("Horizontal") > 0)
{
Sr.flipX = false;
}
else if (Input.GetAxis("Horizontal") < 0)
{
Sr.flipX = true;
}
}
void Jump()
{
//GetAxis
float Y = Input.GetAxis("Jump");
//Jumping Script
if (Grounded == true)
{
if ((Input.GetAxis("Run") > 0) && (Input.GetAxis("Horizontal") != 0))
{
//Running Jump
Tf.Translate(new Vector2(0, Y * RunningJumpPower * Time.deltaTime));
}
else
{
//Normal Jump
Tf.Translate(new Vector2(0, Y * JumpPower * Time.deltaTime));
}
Grounded = false;
}
}
}
↧
In App Purchases & Ads not working in app after publishing to Google Play using Android App Bundle
Hello guys, I recently updated my app to fulfill GPlay requirements of 64 bit support. I uploaded the Android App Bundle built using Unity 2018.3.0f2. The problem is when the apk's are generated by Google play, In App Purchases and Admob Ads are not working. I have even tried using the bundletool to build apk from .aab file on my machine and the ads and IAP don't work still.
Who has faced a similar problem and how did you fix it??
↧
Player respawning after geting two touches
I though my script was going to actually work but it's not... (newbie for coding c#)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ReSpawn : MonoBehaviour
{
private Vector3 spawn;
// Start is called before the first frame update
void Start()
{
spawn = transform.position;
}
void Update()
{
if (transform.position.y < -2)
{
Die();
}
}
void Die()
{
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(1);
transform.position = spawn;
}
}
}
@Bunny83 @Eric5h5 @robertbu @aldonaletto @tanoshimi @duck @whydoidoit @fafase @clunk47 @Statement @Kiwasi @Sebastian 2 @AT-Brackeys
↧