Costin
Costin
CC#
Created by Costin on 4/19/2023 in #help
❔ Make package C private in project A, which inherits project B which uses package C
I have 2 projects, project A and B. project A inherits project B (dependency). however, I want project A to not be able to see project B's NuGet package.
6 replies
CC#
Created by Costin on 1/10/2023 in #help
❔ [Unity] a great code design for Player-AI controller?
So I want to make all characters in my game be both controllable by AI, and also Player can switch to one of them. This includes the players having the exact same action features as AI.
4 replies
CC#
Created by Costin on 1/7/2023 in #help
✅ 3 objects inheritance thing + force call base.DoThing();
So I want to make Class3 inheriting Class2 inheriting abstract Class1, to have Class1's function. Very confusing, but here's what I'm trying to do in code:
public class Class3 : Class2 {
public ... void DoThing() { // any way????
//I would also want to forcely call Class2's DoThing without the programmer removing the base.DoThing();
//code
}
}
public class Class3 : Class2 {
public ... void DoThing() { // any way????
//I would also want to forcely call Class2's DoThing without the programmer removing the base.DoThing();
//code
}
}
public class Class2 : Class1 {
public override void DoThing() {
//code
}
}
public class Class2 : Class1 {
public override void DoThing() {
//code
}
}
public abstract class Class1 {
public abstract void DoThing();
}
public abstract class Class1 {
public abstract void DoThing();
}
Bonus, I would also want to forcely call Class2's DoThing without the programmer removing the base.DoThing();
57 replies
CC#
Created by Costin on 11/9/2022 in #help
❔ Trying to get better at writting code. any advice?
moving = true;
bool canSprint;
if (sprinting)
{
canSprint = true;
// TODO: sprinting system like in SCP: CB
}
else
{
canSprint = false;
}

Vector3 movement = Vector3.zero;
float tempSpeed = canSprint ? sprintSpeed : walkSpeed;
moving = false;
if (speed.x != 0)
{
moving = true;
movement += speed.x * Time.deltaTime * tempSpeed * Vector3.left;
}
if (speed.y != 0)
{
moving = true;
movement += speed.y * Time.deltaTime * tempSpeed * Vector3.back;
}
if (movement != Vector3.zero)
{
transform.Translate(movement);
StepClimb(movement);
}
moving = true;
bool canSprint;
if (sprinting)
{
canSprint = true;
// TODO: sprinting system like in SCP: CB
}
else
{
canSprint = false;
}

Vector3 movement = Vector3.zero;
float tempSpeed = canSprint ? sprintSpeed : walkSpeed;
moving = false;
if (speed.x != 0)
{
moving = true;
movement += speed.x * Time.deltaTime * tempSpeed * Vector3.left;
}
if (speed.y != 0)
{
moving = true;
movement += speed.y * Time.deltaTime * tempSpeed * Vector3.back;
}
if (movement != Vector3.zero)
{
transform.Translate(movement);
StepClimb(movement);
}
Any changes you think can be done in the code above? (do note speed variable is a method argument. the method is called either by "GameManager" that manages player input, or by an AI)
107 replies
CC#
Created by Costin on 10/5/2022 in #help
Pixel-Perfect collision for tile-based game
So I have a 2D tiled Game that has gravity, and players slides with velocity when moving. the max speed can be -16 to 16 both x and y. What I want is to implement pixel-perfect collision, so that when the player jumps or goes through a one tile air, it goes through instead of avoiding it. It's also multiplayer but I already implemented networking. Both players and tiles are 16x16.
225 replies