Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

5 Neutral

About MehdiUBP

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. MehdiUBP

    Skating physics problem

    Hey, thanks for answering. At 0:30, I demonstrate that with slow speed, everything's fine. However, slighthly before at 0:25, there's the problem I'm talking about. Also happens at 0:39. Aerial is just a boolean. Here's the function: void CheckPhysics() { Ray ray = new Ray(transform.position, -transform.up); RaycastHit hit; if(Physics.Raycast(ray, out hit, 1.05f*height)) { if(aerial) { VelocityOnLanding(); } aerial = false; } else { aerial = true; rb.velocity += Vector3.down*AdditionalGravity; } }
  2. MehdiUBP

    Skating physics problem

    Hello y'all I'm making a small skating game, mostly because I'm interested in mechanics but I'm stuck with an orientation problem I can't figure out. To adapt the rotation of the skater with respect to its environment, I break the logic into several components: A PhysicRotation : Returns the Quaternion to go from the skater's transform.up to the normal of the point he's at Quaternion GetPhysicsRotation() { Vector3 target_vec = Vector3.up; Ray ray = new Ray(transform.position, Vector3.down); RaycastHit hit; if(Physics.Raycast(ray, out hit, 1.05f*height)) { target_vec = hit.normal; } return Quaternion.FromToRotation(transform.up, target_vec); } A velocity rotation: So that the character faces the direction he's going. This rotation is contrained to a plane Quaternion GetVelocityRot() { Vector3 vel = rb.velocity; if(vel.magnitude > 0.2f) { vel.y = 0; Vector3 dir = transform.forward; dir.y = 0; Quaternion vel_rot = Quaternion.FromToRotation(dir.normalized, vel.normalized); return vel_rot; } else return Quaternion.identity; } And finally, I an InputRotation that rotates the force applied for moving All of this is then tied in this function: void SkaterMove(Vector2 inputs) { Quaternion PhysicsRotation = aerial ? Quaternion.identity : GetPhysicsRotation(); // Rotation according to ground normal Quaternion VelocityRotation = GetVelocityRot(); Quaternion InputRotation = Quaternion.identity; Quaternion ComputedRotation = Quaternion.identity; if(inputs.magnitude > 0.1f) { Vector3 adapted_direction = CamToPlayer(inputs); Vector3 planar_direction = transform.forward; planar_direction.y = 0; InputRotation = Quaternion.FromToRotation(planar_direction, adapted_direction); if(!aerial) { Vector3 Direction = InputRotation*transform.forward*Speed; rb.AddForce(Direction); } } ComputedRotation = PhysicsRotation*VelocityRotation*transform.rotation; transform.rotation = Quaternion.Lerp(transform.rotation, ComputedRotation, RotatingSpeed*Time.deltaTime); } The thing works rather well, but always stumbles on one specific case. Here's a video I made the explain it better: Basically, when in the quarter, if the character's speed carries him in the air, he does a strange spin and and breaks its flow. I can't figure out where in the code I'm allowing it to do this. I've tried various tests, but I can't figure out where the problem is. Could anyone point me in the good direction ? Thanks !
  3. MehdiUBP

    3D Megascancs

    Hello, How do megascans assets work ? Are they very good because of texture size, polygons number ? I'm a bit lost here. Thanks for the help !
  4. MehdiUBP

    Animation IK

    Hey there ! First results of my solver : IK1.mp4 IK2.mp4 Yep, I know that Overgrowth is not real-time, but I'm mostly interested in sharing animations, hence, it doesn't really matter if they're baked.
  5. MehdiUBP

    Animation IK

    This one is pretty interesting too.
  6. MehdiUBP

    Animation IK

    Thanks y'all for answering. I've started to write an IK solver for experience. I'll let you know as soon as it is done. The whole point of me wanting to learn this is that I want to be able to easily transfer animations from one character to another. I'm making games with Unity and Blender and, well, I'd like to be able to get some procedural animation in the loop.
  7. MehdiUBP

    Animation IK

    Hmm, I more or less get the idea. I started a small script to start experimenting. Here it is. What do you think? The leg streches a bit too much. What could be the next step ? Thanks for your answer anyway ! Capture vidéo 2018-03-12 22:05:46.mp4
  8. Hello, I wrote a MatCap shader following this idea: Given the image representing the texture, we compute the sample point by taking the dot product of the vertex normal and the camera position and remapping this to [0,1]. This seems to work well when I look straight at an object with this shader. However, in cases where the camera points slightly on the side, I can see the texture stretch a lot. Could anyone give me a hint as how to get a nice matcap shader ? Here's what I wrote: Shader "Unlit/Matcap" { Properties { _MainTex ("Texture", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag // make fog work #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float3 normal : NORMAL; }; struct v2f { float2 worldNormal : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _MainTex; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.worldNormal = mul((float3x3)UNITY_MATRIX_V, UnityObjectToWorldNormal(v.normal)).xy*0.3 + 0.5; //UnityObjectToClipPos(v.normal)*0.5 + 0.5; return o; } fixed4 frag (v2f i) : SV_Target { // sample the texture fixed4 col = tex2D(_MainTex, i.worldNormal); // apply fog return col; } ENDCG } } } Thanks!
  9. MehdiUBP

    Animation IK

    Hello, I'm very much interested by this conference and the concepts displayed within. More precisely, I'd like to understand their process for animation sharing. Could anyone help me understand how they do it ? Thanks !
  10. Oh ! I get it ! I'll try this very soon ! Thanks a lot ! EDIT: I'll let you know when I have results
  11. Hello, Made some changes, seems to work now. Far from perfect, but at least, something appears Here's the link https://github.com/Mehd6384/Shaders/blob/master/GeometryGrassShaders.shader
  12. Hey, Thanks to the both of you for your answers. Well, I've tried taking in other geometries: If I start with a triangle, the error disappears, but still no visual triangles/quad.
  13. Hello, I wrote a geometry shader in order to render (in the future, grass) some planes. I get a strange error that I do not understand. It says: The given primitive topology does not match with the topology expected by the geometry shader I do not have the magenta error color, but nothing appears in the scene. Could anyone point me my error ? struct v2g { float4 pos: POSITION; // float3 norm : NORMAL; }; struct g2f { float4 pos : POSITION; // float3 norm : NORMAL ; }; v2g vert(appdata_full v) { // float3 v0 = v.vertex.xyz; v2g o; o.pos = UnityObjectToClipPos(v.vertex); // o.norm = v.normal; return o; } [maxvertexcount(3)] void geom(point v2g v[1], inout TriangleStream <g2f> triStream) { float3 lightPosition = _WorldSpaceLightPos0; float3 perpAngle = float3(1,0,0); float3 up_normal = float3(0,1,0); float3 faceNormal = cross(perpAngle, up_normal); float4 v0 = v[0].pos; float4 v1 = v0; v1.xyz += _GrassWidth*perpAngle; float4 v2 = v1; v2.xyz += (0,1,0)*_GrassHeight; g2f o ; o.pos = UnityObjectToClipPos(v0); triStream.Append(o); o.pos = UnityObjectToClipPos(v1); triStream.Append(o); o.pos = UnityObjectToClipPos(v2); triStream.Append(o); } Thanks a lot !
  14. Hola Comrades ! Thanks for your good answers and great ideas. I've made some inspired adjustments. What do you think ? Thanks again !
  15. Hello ! I've been using Unity to make games for quite a while now, and though I've made a lot of progresses, my games always seem flabby, slacky, too soft. And here, I am talking gameplay. The video may help to understand what I mean. Hence the question: What are the pratices used to make a game feel fast, dynamic ? Thanks for all the answers !
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!